From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=104.47.0.80; helo=eur01-he1-obe.outbound.protection.outlook.com; envelope-from=meenakshi.aggarwal@nxp.com; receiver=edk2-devel@lists.01.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0080.outbound.protection.outlook.com [104.47.0.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BB12C2277AF25 for ; Mon, 23 Apr 2018 03:34:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=eNbQlO6TRVaPT9eYNHJAUkpKvFAciEsTNA30dC14eQE=; b=X8tgD3l02xyuKrIv6hl1HCpe9r/NZ7S6LOO3E6Mgkr2I5RBvy6+fIqoxbN5XNo5W74MfKpL1xwj4pIknKgZgNfZDpMNynrGUfOnE7a4KNPNxNW1yWmzWlTm3nwyXp/htF3PEnuoCXzME4Way55fFgwY8Ieb0bMcBErAWusY+fMM= Received: from DB5PR04MB0998.eurprd04.prod.outlook.com (10.161.199.12) by DB5PR04MB0997.eurprd04.prod.outlook.com (10.161.199.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.13; Mon, 23 Apr 2018 10:34:09 +0000 Received: from DB5PR04MB0998.eurprd04.prod.outlook.com ([fe80::18ce:390:67ab:40af]) by DB5PR04MB0998.eurprd04.prod.outlook.com ([fe80::18ce:390:67ab:40af%15]) with mapi id 15.20.0696.015; Mon, 23 Apr 2018 10:34:08 +0000 From: Meenakshi Aggarwal To: Leif Lindholm CC: "ard.biesheuvel@linaro.org" , "edk2-devel@lists.01.org" , Udit Kumar , Varun Sethi Thread-Topic: [PATCH edk2-platforms 05/39] Silicon/NXP: Add support for I2c driver Thread-Index: AQHTpwOF1gZRq+7Dk0C3HdXgM7lPbaQFhpKAgAjiaDCAAAXWgIAAHncw Date: Mon, 23 Apr 2018 10:34:08 +0000 Message-ID: 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> <20180423083815.wmdb2lu3gqyrmruw@bivouac.eciton.net> In-Reply-To: <20180423083815.wmdb2lu3gqyrmruw@bivouac.eciton.net> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=nxp.com; x-originating-ip: [14.142.187.166] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB5PR04MB0997; 7:gA1zhMXegSDz1B+MObx4Pggb1yRjb5IeeAuAAJFX3sAGT2clvVLka+GETvHux3plPZkPB/FstmNwt8vrZyUhBXCOn8+JfGMFcwomcLDPjSiw+mEJHwo1Eye5+AP7O/0/yM5LL4/jWsJcB1ZNd7baICfjQKEupY+Puo/Kro5tQmeBwlPzjda97vgYDWWSjBrIntDaoDoXbjX+sTSDL9du5RukUwl4wR/BUDNpHJd6BNy3gNPoGu4rcsQjyDeiclha x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020); SRVR:DB5PR04MB0997; x-ms-traffictypediagnostic: DB5PR04MB0997: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197)(162533806227266)(21532816269658); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231232)(944501410)(52105095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:DB5PR04MB0997; BCL:0; PCL:0; RULEID:; SRVR:DB5PR04MB0997; x-forefront-prvs: 06515DA04B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(346002)(39860400002)(366004)(39380400002)(376002)(13464003)(478600001)(7696005)(54906003)(55236004)(33656002)(53936002)(316002)(186003)(93886005)(25786009)(4326008)(6246003)(6436002)(3660700001)(6916009)(229853002)(6116002)(3846002)(2906002)(7736002)(55016002)(8676002)(81166006)(3280700002)(2900100001)(86362001)(76176011)(66066001)(305945005)(8936002)(26005)(102836004)(5660300001)(74316002)(476003)(575784001)(44832011)(11346002)(446003)(5250100002)(9686003)(6506007)(53546011)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR04MB0997; H:DB5PR04MB0998.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; MLV:sfv; x-microsoft-antispam-message-info: s3HumYpUeJU6IeQzukoJIwh6jCoFGpW0rZp3bA7HsephXgU21QKvk/7bM4xTPCycVhQJaBaWSjZrvzPuQnnuFkaZrkDu7xsKr1rul5kFMHdRy8pUcSOFVMxD9e9vaIDT5zNIHw7+RwJHnlYi4ZObBY4dRQ2z/nSl/PGnnlwONSyiiIg3Qb5o0EwZcHVB4NF6 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 33adb822-51be-4343-f24c-08d5a905bf27 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33adb822-51be-4343-f24c-08d5a905bf27 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Apr 2018 10:34:08.8383 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR04MB0997 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 10:34:16 -0000 Content-Language: en-US Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi Leif > -----Original Message----- > From: Leif Lindholm [mailto:leif.lindholm@linaro.org] > Sent: Monday, April 23, 2018 2:08 PM > To: Meenakshi Aggarwal > Cc: ard.biesheuvel@linaro.org; edk2-devel@lists.01.org; Udit Kumar > ; Varun Sethi > Subject: Re: [PATCH edk2-platforms 05/39] Silicon/NXP: Add support for I2= c > driver >=20 > 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 =3D (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. >=20 > 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. >=20 Current board needs one controller. In case of multiple controller, we can use a loop to install multiple proto= cols and=20 If needed then our preference would be to use I2c enumeration protocol.=20 This will allow to use correct controller for connected devices.=20 With sample implementation of SynQuacer code,=20 Please advise, how a right controller is being connected to driver=20 e.g. we are registering two controllers mI2c0Desc and mI2c1Desc and=20 both are exporting same protocols. Its user, RTC lib just checking gEfiI2cMasterProtocolGuid. There is possib= ility=20 to connect with any of the controller. I dont see in code where it is assur= ing connection with right controller. And how we can assure we are connecting to the correct controller. > > There also base address is hard coded SYNQUACER_I2C1_BASE in > > PlatformDxe driver. >=20 > 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. >=20 > / > Leif