From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::235; helo=mail-wr0-x235.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x235.google.com (mail-wr0-x235.google.com [IPv6:2a00:1450:400c:c0c::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B939E2277AF1B for ; Mon, 23 Apr 2018 01:38:19 -0700 (PDT) Received: by mail-wr0-x235.google.com with SMTP id s18-v6so38763389wrg.9 for ; Mon, 23 Apr 2018 01:38:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Fsb/OryN4NVgNA1uFUc+2BA/dBBXkDxCIv/LBnvZi18=; b=HOB6C6BQo0FIm7wpZnYc5y6k2+ojS0TRe7JRbiSBO6VkR+wA/zng9Dmw6qyDk7Piy8 hvj9NA3NWNUOn3WhjTA83fVMqZhgh/VGyrAGeOwcmnUVTOwg2GisXdhRbHjwbPhzPQ+j DtrpLbqrQqMPPUvBP0dHw5UyD+KamxnxmvKRQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Fsb/OryN4NVgNA1uFUc+2BA/dBBXkDxCIv/LBnvZi18=; b=MwlAgwCH4Ptr/huVvOCoEvPHDeqXUzdNiSt9FJub4F86JXqDQ32lZ4tBVEzwgn373A L9YHDqSTf11MAa75LSarv60JLqN9yipf1Vi4midrQv9zT5dVaUztTTWFFBtkzb+fUhuH /XEJAI1Gck0zB+3Bn3LWEgmde5+zd2uBG2j/3F87o1JufeyrmCwqx09EMSir4dHk92My 1dXb0D3qX1TTAGMk0HN4kKH9QizK/JqXWVG02ZhD3ltw2PvxD15tKSrFBNs2NP1DVqdI mhR2XlJtABkwlYKnbUPZTkqoZP/SoAsKWY5kltZGsZK2kIZxDxqM8uc5PybmObKv9KAE sc8w== X-Gm-Message-State: ALQs6tDwlJGsSDgI9lzynkjlTaxK9pH0+8tRjiEDGc9O28r3xkXnWiAd tWFefLL2zDhw7UEPZ6vx+ywrMQ== X-Google-Smtp-Source: AIpwx4/G8CMveawIMwDlMZe15rhvYk6qMm4rUPxpQgU8ddgInGz3bIhdDOGX6hd8mtc7Jm2UDDz1ZA== X-Received: by 10.28.8.212 with SMTP id 203mr9404801wmi.9.1524472697850; Mon, 23 Apr 2018 01:38:17 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id u8sm5044108wmf.3.2018.04.23.01.38.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Apr 2018 01:38:16 -0700 (PDT) Date: Mon, 23 Apr 2018 09:38:15 +0100 From: Leif Lindholm To: Meenakshi Aggarwal Cc: "ard.biesheuvel@linaro.org" , "edk2-devel@lists.01.org" , Udit Kumar , Varun Sethi Message-ID: <20180423083815.wmdb2lu3gqyrmruw@bivouac.eciton.net> References: <1518771035-6733-1-git-send-email-meenakshi.aggarwal@nxp.com> <1518771035-6733-6-git-send-email-meenakshi.aggarwal@nxp.com> <20180417163657.rtmpklak5nqlwn3c@bivouac.eciton.net> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH edk2-platforms 05/39] Silicon/NXP: Add support for I2c driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Apr 2018 08:38:20 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Apr 23, 2018 at 08:21:22AM +0000, Meenakshi Aggarwal wrote: > > > +/** > > > + Function to read data using i2c bus > > > + > > > + @param I2cBus I2c Controller number > > > + @param Chip Address of slave device from where data to be read > > > + @param Offset Offset of slave memory > > > + @param Alen Address length of slave > > > + @param Buffer A pointer to the destination buffer for the data > > > + @param Len Length of data to be read > > > + > > > + @retval EFI_NOT_READY Arbitration lost > > > + @retval EFI_TIMEOUT Failed to initialize data transfer in predefined > > time > > > + @retval EFI_NOT_FOUND ACK was not recieved > > > + @retval EFI_SUCCESS Read was successful > > > + > > > +**/ > > > +STATIC > > > +EFI_STATUS > > > +I2cDataRead ( > > > + IN UINT32 I2cBus, > > > + IN UINT8 Chip, > > > + IN UINT32 Offset, > > > + IN UINT32 Alen, > > > + IN UINT8 *Buffer, > > > + IN UINT32 Len > > > + ) > > > +{ > > > + EFI_STATUS Status; > > > + UINT32 Temp; > > > + INT32 I; > > > + I2C_REGS *I2cRegs; > > > + > > > + I2cRegs = (I2C_REGS *)(FixedPcdGet64 (PcdI2c0BaseAddr + > > > + (I2cBus * FixedPcdGet32 (PcdI2cSize)))); > > > > Please get rid of this hardcoded base address and use NonDiscoverable > > Have a look at Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/ and > > Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/ > > for example. > > > I have checked SynQuacer code and i dont see its adding much advantage. What it gives is the ability to cover more than one controller by this driver, regardless of whether you need it for this particular platform port or not. > There also base address is hard coded SYNQUACER_I2C1_BASE in > PlatformDxe driver. Yes, the PlatformDxe driver statically instantiates dynamic drivers for non-discoverable buses. But there is no longer any hard-coded addresses in the device driver itself. / Leif