From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brijesh Singh Subject: Re: [PATCH] ata: add AMD Seattle platform driver Date: Mon, 11 Jan 2016 12:56:02 -0600 Message-ID: <5693FAC2.4070003@amd.com> References: <1452200002-31590-1-git-send-email-brijesh.singh@amd.com> <10869853.plxna0HzWE@wuerfel> <5690367E.8060609@amd.com> <9923043.nz8DJ6lRiJ@wuerfel> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-bl2on0092.outbound.protection.outlook.com ([65.55.169.92]:51090 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934077AbcAKS6S (ORCPT ); Mon, 11 Jan 2016 13:58:18 -0500 In-Reply-To: <9923043.nz8DJ6lRiJ@wuerfel> Sender: linux-ide-owner@vger.kernel.org List-Id: linux-ide@vger.kernel.org To: Arnd Bergmann Cc: brijesh.singh@amd.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, pawel.moll@arm.com, ijc+devicetree@hellion.org.uk, linux-ide@vger.kernel.org, robh+dt@kernel.org, galak@codeaurora.org, tj@kernel.org Hi Arnd, Thanks for all your valuable feedbacks. On 01/08/2016 04:47 PM, Arnd Bergmann wrote: >> >> libata-*.c implements the "Enclosure management" style led messages but also has hooks >> to register a custom led control callback. Since Seattle platform does not support >> the "Enclosure management" registers hence ata_port_info we are setting a ATA_FLAG_EM | ATA_FLAG_SW_ACIVITY >> to indicate that we can still handle the led messages by our registered callback. I see >> that sata_highbank driver is doing something similar. > > But if the LEDs are the only thing that is special, I think it makes > more sense to extend the generic driver. This is similar to how the > ahci driver knows how to deal with external PHY, clk, regulator etc > resources. All of those are not part of the AHCI spec, but are common > enough that we want to have them done in a single driver. > > We really should not need a special driver just for handling LEDs > when we already deal with more complex stuff, and we have a proper > abstraction for LEDs in the kernel. > I took a quick look at LED class and saw ledtrig-ide-disk.c (ledtrig_ide_activity). It seems this approach was used in deprecate ide-disk driver for blinking the activity led. Are you thinking that we implement something similar in libahci to control the LED blinking? Looking at current libahci gives me feeling that LED's are considered as part of AHCI enclosure management implementation and hence LED triggers are not exposed outside the library. If I am missing something then please correct me. > > A syscon is defined as (roughly) a group of otherwise unrelated registers > that happen to be part of the same physical register area because the SoC > designer couldn't find a proper abstraction for them. When you define > a register area with a single byte in it, that is not a syscon. > >> >> sata@e0300000 { >> compatible = "amd,seattle-ahci"; >> reg = <0x0 0xe0300000 0x0 0xf0000>; >> interrupts = <0x0 0x163 0x4>; >> amd,sgpio-ctrl = <&sgpio0>; >> dma-coherent; >> }; >> > > > The sata node should list "generic-ahci" so we can bind the normal > driver. You can leave the "amd,seattle-ahci" in addition in case we > ever need to know the difference to work around a bug, but it's really > not needed for the LED. > >> SGPIO0 (0xe0000078) and SGPIO1 (0xe000007C) does not belong to any system control register set. >> They are meant to be used by SATA driver only and no other driver should every touch it. It almost feels >> its just extension of the IP block but it just happened to be way out of the IP block range. >> Other register near to 0xe000_0078 and 0xe000_007C should not be mapped by OS. > > That is quite normal, a lot of chips have register blocks where one > register is meant for one device only. E.g. the clock controller may have > one register for controlling the clocks of the AHCI device. In the old > days, we would have hacks like what you did to turn on the clocks by poking > the register from the SATA driver, but now we abstract those things using > generic subsystems. > > I think you either want a special led controller device node that > refers to the syscon device and exports the LEDs so they can be > accessed by the AHCI device, or do it in the device that contains > the registers. > >> But this syscon approach also brings another problem. Currently my code is pretty simple for mapping this regs >> >> + plat_data->sgpio_ctrl = devm_ioremap_resource(dev, >> + platform_get_resource(pdev, IORESOURCE_MEM, 1)); >> + if (IS_ERR(plat_data->sgpio_ctrl)) >> + return &ahci_port_info; >> + >> >> The above code works on ACPI and DT cases. But if we go with syncon approach >> then we need to handle DT and ACPI differently. Because sycon will provide >> struct regmap instead of struct resources and also make reading/writing a >> bit different. I was trying to minimize the DT vs ACPI changes in the driver >> (other than binding) hence I think defining two ranges in sata controller >> reg property was much cleaner and it aligns with DSDT. > > Isn't this the thing that ACPI based firmware would handle using AML anyway? > I don't think the server people would be too happy to add a new driver > each time a SATA controller does the LEDs slightly differently, and this > is really the kind of platform specific hack that AML is meant for. > Sorry I am not able understand your comment, Could you please explain me what you mean by AML is meant for this kind of platform specific hack ? "SATA0" and "SATA1" DSDT Resource template contains two resources (#0 SATA block register and #1 SGPIO control register). Device (SATA0) { Name(_CRS, ResourceTemplate() { Memory32Fixed(ReadWrite, 0xE03000000, 0x000010000) Interrupt(ResourceConsumer, Level, ActiveHigh Exclusive,,,) { 387} Memory32Fixed(ReadWrite, 0xE00000078, 1) } } Device (SATA1) { Name(_CRS, ResourceTemplate() { Memory32Fixed(ReadWrite, 0xE0D100000, 0x000010000) Interrupt(ResourceConsumer, Level, ActiveHigh Exclusive,,,) { 393} Memory32Fixed(ReadWrite, 0xE0000007C, 1) } } The generic ahci platform driver calls ahci_platform_get_resources() to get the resources. ahci_platform_get_resources() maps the resource #0. Since the SGPIO control resource is part of SATA device resource hence I could simply ioremap resource #1 for both DT and ACPI cases. Since windows driver is making use of same DSDT hence its going to be tricky to modify the DSDT to create a new device entry for SATA LED. Before creating a new driver, I did attempt to extend the existing ahci_platform driver and was able to get it working but it was not looking good hence created a new driver. One of the issue was knowing when to map the SGPIO control register in ACPI case. ahci_platform driver does binding based on _CLS mask so I was not sure whether doing ioremap of resource#1 is safe and would not cause problem on non Seattle platform. If you want then i can send you patch for quick comment and see if that make sense instead of adding a new driver. > Arnd > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934107AbcAKS6U (ORCPT ); Mon, 11 Jan 2016 13:58:20 -0500 Received: from mail-bl2on0092.outbound.protection.outlook.com ([65.55.169.92]:51090 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934077AbcAKS6S (ORCPT ); Mon, 11 Jan 2016 13:58:18 -0500 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=permerror action=none header.from=amd.com; X-WSS-ID: 0O0SY0Z-08-CGR-02 X-M-MSG: Subject: Re: [PATCH] ata: add AMD Seattle platform driver To: Arnd Bergmann References: <1452200002-31590-1-git-send-email-brijesh.singh@amd.com> <10869853.plxna0HzWE@wuerfel> <5690367E.8060609@amd.com> <9923043.nz8DJ6lRiJ@wuerfel> CC: , , , , , , , , , , From: Brijesh Singh Message-ID: <5693FAC2.4070003@amd.com> Date: Mon, 11 Jan 2016 12:56:02 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <9923043.nz8DJ6lRiJ@wuerfel> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(428002)(3190300001)(377454003)(24454002)(69224002)(479174004)(199003)(189002)(87936001)(86362001)(92566002)(575784001)(80316001)(19580405001)(23746002)(230700001)(54356999)(65806001)(87266999)(110136002)(77096005)(189998001)(2950100001)(64126003)(59896002)(36756003)(93886004)(65956001)(101416001)(33656002)(50466002)(76176999)(5008740100001)(50986999)(4326007)(83506001)(97736004)(2906002)(586003)(6116002)(106466001)(3846002)(5004730100002)(1096002)(65816999)(4001350100001)(47776003)(105586002)(1220700001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR12MB0863;H:atltwp02.amd.com;FPR:;SPF:None;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0863;2:6svU4RBWRao3CmkTHJkpBl6ojWCDqM2q4QzVfX3qZoV4dUJ3JsmODDTcl8mNkdnvTbpE7b7tx57j1Qx53LisiYmBqX26BlXqJk3DUxdm+vbZulR5VVS7/WAsMEfig0ZyiHIoLJUMaZNf2fRg3SDmtw==;3:p2lT5aHYn8ONHuNlwykphv5IFUG1tHpj2b+4hLwuTlnEcscLQz0tdroGuhWBeL5RO/XXBdJ2pBRuXEQjkFT6JycV73ikDdNPm4fNHQ6lMLRDZsfEDLRM5kr4hx+vzxJ7Fz3ksrDbKxC0qa0XkDvTkYXXLOr83YChiRdVwkn6Nd64mBZxBr4wu0QSMWSvt9Eq1Yq+VwS/io1qJzls0mgL3kMhyjmIxbnbEInD2f5Bxn4=;25:U+bdpzSuedc8zcLRn6fVvg5i6ZkhG7Z0U9WpZEzJJ90+G2nl59dKForlExbF+r5Dpj2q7rfAuRSIoHsqIkRHBgA9cXjm+haL5lPAAGHVf5p8mdAP8hfQl2aA+ABH5bg5PT6NFKEB4vLV+iSzTw5XsjuqnzBbqs778mDRrKxYUSMhjUQpCZKUvg3IGZVX8Zg5KArW6veFY67zGs+OlEFCse1Z+rKr1aqra9gwV82ydLRnDB1U9wG/ggDxnfPUHLBq X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0863; X-MS-Office365-Filtering-Correlation-Id: c968d56a-567b-4420-5cc1-08d31ab92902 X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0863;20:r9G3Ty47JzUoZCTKOuv8rfxLYSjMWtseXMCIAr7w17llH5Ye+/5uAaECZ9GkFsBrcrDJ+GSaGOR+vItB1rPRiXCWpeihJmOhGVXPi3i2MW+FIdUfq8VeEITePRNb3OgaILN73U8xIvaW2kzJHYwtcqObh0Ukp+VJHARyYycxzJa68Z4ylpD+f7H8CgZ+mj0FZxCx+ROeP70Jft0XJdDEER7r1KKBqCQaBun/41tA5/b7FX9GmDEqbaeMxA6jwaldpi4oNLKDyTb0OucPyulJkn9HQCH9JnpFzUTINGZe7lpzBk3N6wl6Toz6Go+Br92cPQX79oDr1oacp6Vh/KbqGJw0sBjm+iCZWbpLUH7xcv3kdFAP1lY++KzyyVWWv/DZnELt4Q3Afuw/kSk7v6IIPZoVFhH4PVYpWQaZmRBR+4qBHu9Ax1OItNjoYWZaZGid2qn2eJHlcJYxShhvrGI4hRGriFzyEBYuvvIpgr/qO8U32RPCBvsPfgd/THtCqHRi;4:YTnJEUso/hPfCoshpge7rXkqC9ttQz0BJ/VrLHiE3fB74UE0Fsrf69es0SRlypa+a+wzxupKkl2oGzmJ7fSpSvtAWiLIUvDymoF6ZEwExlXLVPjsBfNWGklI1XLUaGqZi54cBVI8Z2Tor4gAOB0J6BRbEsxWr7mjc3y+Nce9Or/JuUfvnx4Wj5CmHK2txxNh9zr4qfGfLAoCkr7KaBlbQl8tDvbVW1C9yoYyMbXC7UOjaaEoFgltUUGTVGWZa3JNwI3jGMeP/KP7yWF2pofDfkgiKfNLY8mHgSjsz+XJSJ+7EG8SPk56WrPvocwSNf1vphThTMo/31eEn5b7DcwbQ65aoGEHj0hUhG+5xaMNygf/6t2byH8R5WyXUIsBNxPUsaOJXyh/URNoAYsgKqf36MIXU8jAngxm34aRIXp5g1WBcUMCSyDXXgsH1Cz+H8ob X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13018025)(5005006)(13015025)(13017025)(520078)(8121501046)(10201501046)(3002001);SRVR:SN1PR12MB0863;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0863; X-Forefront-PRVS: 0818724663 X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;SN1PR12MB0863;23:G19gdIfdWdL1sDXlXPcSDUyMLcGAyLnkNuEmy?= =?Windows-1252?Q?4COzf8N6oqpVpkIdwsst2dVH7xFCTvMnN2beF+O063ZkYUMiR4tqY7C1?= =?Windows-1252?Q?cwkTFNjuMPWtI6Ybl7QPowmDlzyw27lfOs4vDyjHyjb7YF1WXgzMRyya?= =?Windows-1252?Q?X4P3zQNjsqDZjfD1AprrQMksNpA/aJQfyrdq6MnbA1H02aPGdIjFonva?= =?Windows-1252?Q?7Qt51BpoI2In23FV9wzIgN7dd9c96KS5BoJg6uSJlpwAvn0uj1X3Ht1n?= =?Windows-1252?Q?hR4qnfrKdndesNBs2MWriPvqFXPk5hKl8Lcv5X/mfJzlT2Z1uiCi8JJL?= =?Windows-1252?Q?T+zmVrT6a7hTKYsVK7MpsYsH7QF1OQVaUQKfnGOIYQsuQsJ8l8t62Gcg?= =?Windows-1252?Q?XP6wUNtuqU3Xcuc5WqoWUn711qtm72veCziZ5ZBEM58UaAz6SwIYfWMH?= =?Windows-1252?Q?PGe400EpdT6V6byIQaeAv1bt8QFI/DIXAi222usikKU46SVCFVkZoqi1?= =?Windows-1252?Q?jfuetX7pHv+PwC8b1skUukDIxZt1N+dmyl+2XCbAVxGfXNHlaLz5OLnl?= =?Windows-1252?Q?VRxdObICX0HOfvZuoMfem6IanPfVUQdibNEXZfqpkrLfoEkZXvorzu1O?= =?Windows-1252?Q?SVZodpzUuXpOz24P1qpjXwXbEQzlZYwCDXmW7yb/DqFU4Hs89eA0wYzg?= =?Windows-1252?Q?/KOXQyQkCnwgfR0i+A9YDZqw9fXC1cjf4+q0O9Bv7UI8rv+1okwPSrEV?= =?Windows-1252?Q?RzoIhIHKosoPgpAj7sSs5PFEstTNfm9XS2b1+iXnt5mr3DevMo9v+c1N?= =?Windows-1252?Q?EGGGXj6qiuf4CcDdAkl+sZjwIREYNCaD2An9ELVbuZuhmEIBGy+u1mSh?= =?Windows-1252?Q?wLpdiqqyPtPMW2aPn7tXV5hEcdemTS/AReuxVwPdgbDKRPh6SJBZPOZj?= =?Windows-1252?Q?o/ehL7vJbkBJRgO4CUkbIYuh7r8XxoOHN7cmGziZRm0Ts7hzzdKT5vnk?= =?Windows-1252?Q?lXowC1WBESBAyz6wbDl3hg6gqodzb8KeSvyyC8s2NONp1whHyEHYYMYT?= =?Windows-1252?Q?Em2cQUkq0PXq3QlMvqX5AkAunxaZCWQ+c4ZUwOMPu7Qbct6zFc0XRKf0?= =?Windows-1252?Q?d2OMZLNvlljyyBsrTyI7VYwSGNME4luFCL+tAwy7BDaAftOLMkXstKF2?= =?Windows-1252?Q?AjBhbrUGT1mgfpB5ESJm914w2+NzhJli6QIuRjUBHICxbNQZ4CBDfHGF?= =?Windows-1252?Q?ot2K/e1eIbvZ4K8XM3l+pUxXuqN/tsauha2H8i/5N6KRZFCmuxgoLw16?= =?Windows-1252?Q?V6y79g9R0FhBLXUIqC47/VjSgC+hgV+v6SXfGvlsUMDuvHr+1fXSb2T9?= =?Windows-1252?Q?T20Gf/WqicyUJyXWyXhJHZXgHBOksL8Sg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0863;5:gbIhr+MSyBMhT2BpLHOGsfd4JgeGtDQDrfeHKDKp6PjFTYrbNUPR78LGoP7b3LLrydQkC1nCvDHsByL4x5lv2bsCSDt8hX3WkUN3mZhBKsoXLd5aqQ/zSP/HzCH99Vph4Q1A0mkykzwn94SmB3ax5A==;24:zt7Nyoc2tUuP7eIVXfuXozpmE+FVD5gZoK5hVogb6XNQmGmDfmED5XNl7y2/6Q859w3VK0dqaQC6AS3AaLegZp+SdssFeQppeLiP29Y9SvA=;20:7pqd/PoLleYa7tnisc2x+V7n1r+Nwmuo77+FAhpvkbyjmTvgtIdrytaKikEAo/dn37G9drPNzEZs8yk+mkAzm1nzynt/rX5yPaCtqCXFDJI4nx1sAhH6U8mtLuj2jfUkhtEcV7ZhsgO7CwkJrecJmvqOz7/1UFM6KvwmZO4T2ZHdcUl+c6/UlBL2ALvjWWRigGetyjmvgBnCDgrndlV/oQCI8ypucmuLTByBcVJZ+7uqGOJAWhdKKgamWQ6DcTDS SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2016 18:58:13.5539 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.222];Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0863 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnd, Thanks for all your valuable feedbacks. On 01/08/2016 04:47 PM, Arnd Bergmann wrote: >> >> libata-*.c implements the "Enclosure management" style led messages but also has hooks >> to register a custom led control callback. Since Seattle platform does not support >> the "Enclosure management" registers hence ata_port_info we are setting a ATA_FLAG_EM | ATA_FLAG_SW_ACIVITY >> to indicate that we can still handle the led messages by our registered callback. I see >> that sata_highbank driver is doing something similar. > > But if the LEDs are the only thing that is special, I think it makes > more sense to extend the generic driver. This is similar to how the > ahci driver knows how to deal with external PHY, clk, regulator etc > resources. All of those are not part of the AHCI spec, but are common > enough that we want to have them done in a single driver. > > We really should not need a special driver just for handling LEDs > when we already deal with more complex stuff, and we have a proper > abstraction for LEDs in the kernel. > I took a quick look at LED class and saw ledtrig-ide-disk.c (ledtrig_ide_activity). It seems this approach was used in deprecate ide-disk driver for blinking the activity led. Are you thinking that we implement something similar in libahci to control the LED blinking? Looking at current libahci gives me feeling that LED's are considered as part of AHCI enclosure management implementation and hence LED triggers are not exposed outside the library. If I am missing something then please correct me. > > A syscon is defined as (roughly) a group of otherwise unrelated registers > that happen to be part of the same physical register area because the SoC > designer couldn't find a proper abstraction for them. When you define > a register area with a single byte in it, that is not a syscon. > >> >> sata@e0300000 { >> compatible = "amd,seattle-ahci"; >> reg = <0x0 0xe0300000 0x0 0xf0000>; >> interrupts = <0x0 0x163 0x4>; >> amd,sgpio-ctrl = <&sgpio0>; >> dma-coherent; >> }; >> > > > The sata node should list "generic-ahci" so we can bind the normal > driver. You can leave the "amd,seattle-ahci" in addition in case we > ever need to know the difference to work around a bug, but it's really > not needed for the LED. > >> SGPIO0 (0xe0000078) and SGPIO1 (0xe000007C) does not belong to any system control register set. >> They are meant to be used by SATA driver only and no other driver should every touch it. It almost feels >> its just extension of the IP block but it just happened to be way out of the IP block range. >> Other register near to 0xe000_0078 and 0xe000_007C should not be mapped by OS. > > That is quite normal, a lot of chips have register blocks where one > register is meant for one device only. E.g. the clock controller may have > one register for controlling the clocks of the AHCI device. In the old > days, we would have hacks like what you did to turn on the clocks by poking > the register from the SATA driver, but now we abstract those things using > generic subsystems. > > I think you either want a special led controller device node that > refers to the syscon device and exports the LEDs so they can be > accessed by the AHCI device, or do it in the device that contains > the registers. > >> But this syscon approach also brings another problem. Currently my code is pretty simple for mapping this regs >> >> + plat_data->sgpio_ctrl = devm_ioremap_resource(dev, >> + platform_get_resource(pdev, IORESOURCE_MEM, 1)); >> + if (IS_ERR(plat_data->sgpio_ctrl)) >> + return &ahci_port_info; >> + >> >> The above code works on ACPI and DT cases. But if we go with syncon approach >> then we need to handle DT and ACPI differently. Because sycon will provide >> struct regmap instead of struct resources and also make reading/writing a >> bit different. I was trying to minimize the DT vs ACPI changes in the driver >> (other than binding) hence I think defining two ranges in sata controller >> reg property was much cleaner and it aligns with DSDT. > > Isn't this the thing that ACPI based firmware would handle using AML anyway? > I don't think the server people would be too happy to add a new driver > each time a SATA controller does the LEDs slightly differently, and this > is really the kind of platform specific hack that AML is meant for. > Sorry I am not able understand your comment, Could you please explain me what you mean by AML is meant for this kind of platform specific hack ? "SATA0" and "SATA1" DSDT Resource template contains two resources (#0 SATA block register and #1 SGPIO control register). Device (SATA0) { Name(_CRS, ResourceTemplate() { Memory32Fixed(ReadWrite, 0xE03000000, 0x000010000) Interrupt(ResourceConsumer, Level, ActiveHigh Exclusive,,,) { 387} Memory32Fixed(ReadWrite, 0xE00000078, 1) } } Device (SATA1) { Name(_CRS, ResourceTemplate() { Memory32Fixed(ReadWrite, 0xE0D100000, 0x000010000) Interrupt(ResourceConsumer, Level, ActiveHigh Exclusive,,,) { 393} Memory32Fixed(ReadWrite, 0xE0000007C, 1) } } The generic ahci platform driver calls ahci_platform_get_resources() to get the resources. ahci_platform_get_resources() maps the resource #0. Since the SGPIO control resource is part of SATA device resource hence I could simply ioremap resource #1 for both DT and ACPI cases. Since windows driver is making use of same DSDT hence its going to be tricky to modify the DSDT to create a new device entry for SATA LED. Before creating a new driver, I did attempt to extend the existing ahci_platform driver and was able to get it working but it was not looking good hence created a new driver. One of the issue was knowing when to map the SGPIO control register in ACPI case. ahci_platform driver does binding based on _CLS mask so I was not sure whether doing ioremap of resource#1 is safe and would not cause problem on non Seattle platform. If you want then i can send you patch for quick comment and see if that make sense instead of adding a new driver. > Arnd > From mboxrd@z Thu Jan 1 00:00:00 1970 From: brijesh.singh@amd.com (Brijesh Singh) Date: Mon, 11 Jan 2016 12:56:02 -0600 Subject: [PATCH] ata: add AMD Seattle platform driver In-Reply-To: <9923043.nz8DJ6lRiJ@wuerfel> References: <1452200002-31590-1-git-send-email-brijesh.singh@amd.com> <10869853.plxna0HzWE@wuerfel> <5690367E.8060609@amd.com> <9923043.nz8DJ6lRiJ@wuerfel> Message-ID: <5693FAC2.4070003@amd.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Arnd, Thanks for all your valuable feedbacks. On 01/08/2016 04:47 PM, Arnd Bergmann wrote: >> >> libata-*.c implements the "Enclosure management" style led messages but also has hooks >> to register a custom led control callback. Since Seattle platform does not support >> the "Enclosure management" registers hence ata_port_info we are setting a ATA_FLAG_EM | ATA_FLAG_SW_ACIVITY >> to indicate that we can still handle the led messages by our registered callback. I see >> that sata_highbank driver is doing something similar. > > But if the LEDs are the only thing that is special, I think it makes > more sense to extend the generic driver. This is similar to how the > ahci driver knows how to deal with external PHY, clk, regulator etc > resources. All of those are not part of the AHCI spec, but are common > enough that we want to have them done in a single driver. > > We really should not need a special driver just for handling LEDs > when we already deal with more complex stuff, and we have a proper > abstraction for LEDs in the kernel. > I took a quick look at LED class and saw ledtrig-ide-disk.c (ledtrig_ide_activity). It seems this approach was used in deprecate ide-disk driver for blinking the activity led. Are you thinking that we implement something similar in libahci to control the LED blinking? Looking at current libahci gives me feeling that LED's are considered as part of AHCI enclosure management implementation and hence LED triggers are not exposed outside the library. If I am missing something then please correct me. > > A syscon is defined as (roughly) a group of otherwise unrelated registers > that happen to be part of the same physical register area because the SoC > designer couldn't find a proper abstraction for them. When you define > a register area with a single byte in it, that is not a syscon. > >> >> sata at e0300000 { >> compatible = "amd,seattle-ahci"; >> reg = <0x0 0xe0300000 0x0 0xf0000>; >> interrupts = <0x0 0x163 0x4>; >> amd,sgpio-ctrl = <&sgpio0>; >> dma-coherent; >> }; >> > > > The sata node should list "generic-ahci" so we can bind the normal > driver. You can leave the "amd,seattle-ahci" in addition in case we > ever need to know the difference to work around a bug, but it's really > not needed for the LED. > >> SGPIO0 (0xe0000078) and SGPIO1 (0xe000007C) does not belong to any system control register set. >> They are meant to be used by SATA driver only and no other driver should every touch it. It almost feels >> its just extension of the IP block but it just happened to be way out of the IP block range. >> Other register near to 0xe000_0078 and 0xe000_007C should not be mapped by OS. > > That is quite normal, a lot of chips have register blocks where one > register is meant for one device only. E.g. the clock controller may have > one register for controlling the clocks of the AHCI device. In the old > days, we would have hacks like what you did to turn on the clocks by poking > the register from the SATA driver, but now we abstract those things using > generic subsystems. > > I think you either want a special led controller device node that > refers to the syscon device and exports the LEDs so they can be > accessed by the AHCI device, or do it in the device that contains > the registers. > >> But this syscon approach also brings another problem. Currently my code is pretty simple for mapping this regs >> >> + plat_data->sgpio_ctrl = devm_ioremap_resource(dev, >> + platform_get_resource(pdev, IORESOURCE_MEM, 1)); >> + if (IS_ERR(plat_data->sgpio_ctrl)) >> + return &ahci_port_info; >> + >> >> The above code works on ACPI and DT cases. But if we go with syncon approach >> then we need to handle DT and ACPI differently. Because sycon will provide >> struct regmap instead of struct resources and also make reading/writing a >> bit different. I was trying to minimize the DT vs ACPI changes in the driver >> (other than binding) hence I think defining two ranges in sata controller >> reg property was much cleaner and it aligns with DSDT. > > Isn't this the thing that ACPI based firmware would handle using AML anyway? > I don't think the server people would be too happy to add a new driver > each time a SATA controller does the LEDs slightly differently, and this > is really the kind of platform specific hack that AML is meant for. > Sorry I am not able understand your comment, Could you please explain me what you mean by AML is meant for this kind of platform specific hack ? "SATA0" and "SATA1" DSDT Resource template contains two resources (#0 SATA block register and #1 SGPIO control register). Device (SATA0) { Name(_CRS, ResourceTemplate() { Memory32Fixed(ReadWrite, 0xE03000000, 0x000010000) Interrupt(ResourceConsumer, Level, ActiveHigh Exclusive,,,) { 387} Memory32Fixed(ReadWrite, 0xE00000078, 1) } } Device (SATA1) { Name(_CRS, ResourceTemplate() { Memory32Fixed(ReadWrite, 0xE0D100000, 0x000010000) Interrupt(ResourceConsumer, Level, ActiveHigh Exclusive,,,) { 393} Memory32Fixed(ReadWrite, 0xE0000007C, 1) } } The generic ahci platform driver calls ahci_platform_get_resources() to get the resources. ahci_platform_get_resources() maps the resource #0. Since the SGPIO control resource is part of SATA device resource hence I could simply ioremap resource #1 for both DT and ACPI cases. Since windows driver is making use of same DSDT hence its going to be tricky to modify the DSDT to create a new device entry for SATA LED. Before creating a new driver, I did attempt to extend the existing ahci_platform driver and was able to get it working but it was not looking good hence created a new driver. One of the issue was knowing when to map the SGPIO control register in ACPI case. ahci_platform driver does binding based on _CLS mask so I was not sure whether doing ioremap of resource#1 is safe and would not cause problem on non Seattle platform. If you want then i can send you patch for quick comment and see if that make sense instead of adding a new driver. > Arnd >