ARM: mach-shmobile: r8a7779: add SATA support
PATCH v4 2/3 ARM: mach-shmobile: r8a7779: add SATA support
From: Vladimir Barinov <[email protected]>
Add SATA clock for r8a7779 SoC (for both device tree and usual cases). Register SATA controller as a "late" platform device on r8a7779 SoC.
---
Changes since v3:
- recast to apply to the recent 'next' branch.
Changes since v1:
- added new clock entry for the device tree case instead of the entry in r8a7779_auxdata_lookup[];
- initialized sata_device.dev.[coherent_]dma_mask;
- created r8a7779_late_devices[], add SATA device there, and register "late" devices from r8a7779_add_standard_devices();
arch/arm/mach-shmobile/clock-r8a7779.c | 4 ++++ arch/arm/mach-shmobile/setup-r8a7779.c | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
Index: renesas/arch/arm/mach-shmobile/clock-r8a7779.c =================================--- renesas.orig/arch/arm/mach-shmobile/clock-r8a7779.c +++ renesas/arch/arm/mach-shmobile/clock-r8a7779.c
@@ -87,6 +87,7 @@ static struct clk div4_clks[DIV4_NR] = {
};
enum { MSTP323, MSTP322, MSTP321, MSTP320,
+ MSTP115,
MSTP101, MSTP100,
MSTP030,
MSTP029, MSTP028, MSTP027, MSTP026, MSTP025, MSTP024, MSTP023, MSTP022, MSTP021,
@@ -99,6 +100,7 @@ static struct clk mstp_clks[MSTP_NR] = {
[MSTP322] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR3, 22, 0), /* SDHI1 */ [MSTP321] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR3, 21, 0), /* SDHI2 */ [MSTP320] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR3, 20, 0), /* SDHI3 */
+ [MSTP115] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 15, 0), /* SATA */
[MSTP101] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 1, 0), /* USB2 */ [MSTP100] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 0, 0), /* USB0/1 */ [MSTP030] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 30, 0), /* I2C0 */
@@ -156,6 +158,8 @@ static struct clk_lookup lookups[] = {
CLKDEV_CON_ID("peripheral_clk", &div4_clks[DIV4_P]),
/* MSTP32 clocks */
+ CLKDEV_DEV_ID("sata_rcar", &mstp_clks[MSTP115]), /* SATA */
+ CLKDEV_DEV_ID("fc600000.sata", &mstp_clks[MSTP115]), /* SATA w/DT */
CLKDEV_DEV_ID("ehci-platform.1", &mstp_clks[MSTP101]), /* USB EHCI port2 */ CLKDEV_DEV_ID("ohci-platform.1", &mstp_clks[MSTP101]), /* USB OHCI port2 */ CLKDEV_DEV_ID("ehci-platform.0", &mstp_clks[MSTP100]), /* USB EHCI port0/1 */
Index: renesas/arch/arm/mach-shmobile/setup-r8a7779.c =================================--- renesas.orig/arch/arm/mach-shmobile/setup-r8a7779.c +++ renesas/arch/arm/mach-shmobile/setup-r8a7779.c
@@ -29,6 +29,7 @@
#include <linux/serial_sci.h>
#include <linux/sh_intc.h>
#include <linux/sh_timer.h>
+#include <linux/dma-mapping.h>
#include <mach/hardware.h>
#include <mach/irqs.h>
#include <mach/r8a7779.h>
@@ -322,6 +323,30 @@ static struct platform_device i2c3_devic
.num_resources = ARRAY_SIZE(rcar_i2c3_res),
};
+static struct resource sata_resources[] = {
+ [0] = {
+ .name = "rcar-sata",
+ .start = 0xfc600000,
+ .end = 0xfc601fff,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = gic_spi(100),
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct platform_device sata_device = {
+ .name = "sata_rcar",
+ .id = -1,
+ .resource = sata_resources,
+ .num_resources = ARRAY_SIZE(sata_resources),
+ .dev = {
+ .dma_mask = &sata_device.dev.coherent_dma_mask,
+ .coherent_dma_mask = DMA_BIT_MASK(32),
+ },
+};
+
static struct platform_device *r8a7779_devices_dt[] __initdata = {
&scif0_device,
&scif1_device,
@@ -338,6 +363,7 @@ static struct platform_device *r8a7779_l
&i2c1_device,
&i2c2_device,
&i2c3_device,
+ &sata_device,
};
void __init r8a7779_add_standard_devices(void)
PATCH v4 2/3 ARM: mach-shmobile: r8a7779: add SATA support
Quoted 4 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add SATA clock for r8a7779 SoC (for both device tree and usual cases). Register SATA controller as a "late" platform device on r8a7779 SoC.
Hi,
If you have the a binding in the device tree (which you do through patch 1/3), then there's no reason to have a platform device for it.
-Olof
PATCH v4 2/3 ARM: mach-shmobile: r8a7779: add SATA support
Quoted 10 lines · Olof Johansson
Quoted 4 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add SATA clock for r8a7779 SoC (for both device tree and usual cases). Register SATA controller as a "late" platform device on r8a7779 SoC.
Hi,
If you have the a binding in the device tree (which you do through patch 1/3), then there's no reason to have a platform device for it.
Hi Olof,
the DT exists but currently the marzen board brings up all of its devices using platform devices. Which if nothing else is internally consistent.
I suppose it would be possible to add a call to r8a7779_add_standard_devices_dt() and have the board bring up this device using DT and the rest using platform drivers (until the drivers are migrated to DT).
Would that be your preferred option?
Magnus, how do you feel about this idea?
PATCH v4 2/3 ARM: mach-shmobile: r8a7779: add SATA support
Quoted 18 lines · Simon Horman
Quoted 10 lines · Olof Johansson
Quoted 4 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add SATA clock for r8a7779 SoC (for both device tree and usual cases). Register SATA controller as a "late" platform device on r8a7779 SoC.
Hi,
If you have the a binding in the device tree (which you do through patch 1/3), then there's no reason to have a platform device for it.
Hi Olof,
the DT exists but currently the marzen board brings up all of its devices using platform devices. Which if nothing else is internally consistent.
Quoted 8 lines
I suppose it would be possible to add a call to
r8a7779_add_standard_devices_dt()and have the board bring up this device using DT and the rest using platform drivers (until the drivers are migrated to DT).Would that be your preferred option?
Magnus, how do you feel about this idea?
Ping.
PATCH v4 2/3 ARM: mach-shmobile: r8a7779: add SATA support
Quoted 24 lines · Simon Horman
Quoted 23 lines · Simon Horman
Quoted 10 lines · Olof Johansson
Quoted 4 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add SATA clock for r8a7779 SoC (for both device tree and usual cases). Register SATA controller as a "late" platform device on r8a7779 SoC.
Hi,
If you have the a binding in the device tree (which you do through patch 1/3), then there's no reason to have a platform device for it.
Hi Olof,
the DT exists but currently the marzen board brings up all of its devices using platform devices. Which if nothing else is internally consistent.
I suppose it would be possible to add a call to
r8a7779_add_standard_devices_dt()and have the board bring up this device using DT and the rest using platform drivers (until the drivers are migrated to DT).
Quoted 5 lines
Quoted 3 lines
Would that be your preferred option?
Magnus, how do you feel about this idea?
Ping.
Sorry, I know the ping wasn't directed at me, but I didn't reply yet either. :)
This is generally the right migration model for platforms that have some regular platform devices today; register what isn't yet DT enabled through the old ways, but also probe device tree for the devices that are described there.
You might need AUXDATA tables to get clock names right (since device names are different) until you have clock bindings, that's what other platforms have done as well. Over time you can migrate away from it and switch to only DT.
-Olof
PATCH v4 2/3 ARM: mach-shmobile: r8a7779: add SATA support
Quoted 38 lines · Olof Johansson
Quoted 24 lines · Simon Horman
Quoted 23 lines · Simon Horman
Quoted 10 lines · Olof Johansson
Quoted 4 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add SATA clock for r8a7779 SoC (for both device tree and usual cases). Register SATA controller as a "late" platform device on r8a7779 SoC.
Hi,
If you have the a binding in the device tree (which you do through patch 1/3), then there's no reason to have a platform device for it.
Hi Olof,
the DT exists but currently the marzen board brings up all of its devices using platform devices. Which if nothing else is internally consistent.
I suppose it would be possible to add a call to
r8a7779_add_standard_devices_dt()and have the board bring up this device using DT and the rest using platform drivers (until the drivers are migrated to DT).Quoted 5 lines
Quoted 3 lines
Would that be your preferred option?
Magnus, how do you feel about this idea?
Ping.
Sorry, I know the ping wasn't directed at me, but I didn't reply yet either. :)
This is generally the right migration model for platforms that have some regular platform devices today; register what isn't yet DT enabled through the old ways, but also probe device tree for the devices that are described there.
Quoted 4 lines
You might need AUXDATA tables to get clock names right (since device names are different) until you have clock bindings, that's what other platforms have done as well. Over time you can migrate away from it and switch to only DT.
Thanks. Unless Magnus has an objection I will make it so.
PATCH v4 2/3 ARM: mach-shmobile: r8a7779: add SATA support
In reply to Simon HormanHi Simon
Quoted 18 lines · Simon Horman
Quoted 10 lines · Olof Johansson
Quoted 4 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add SATA clock for r8a7779 SoC (for both device tree and usual cases). Register SATA controller as a "late" platform device on r8a7779 SoC.
Hi,
If you have the a binding in the device tree (which you do through patch 1/3), then there's no reason to have a platform device for it.
Hi Olof,
the DT exists but currently the marzen board brings up all of its devices using platform devices. Which if nothing else is internally consistent.
Quoted 8 lines
I suppose it would be possible to add a call to
r8a7779_add_standard_devices_dt()and have the board bring up this device using DT and the rest using platform drivers (until the drivers are migrated to DT).Would that be your preferred option?
Magnus, how do you feel about this idea?
I fail to see the upside I'm afraid.
I believe the best way forward is for us to keep on following the same style as we have done so far. So for drivers they should begin by interfacing as regular platform devices drivers and then add DT support incrementally. This allows us to try out things in a non-ABI kind of way and it also allows us to add support for various hardware feature that do not yet support DT like in the case of DMA Engine. With platform devices we can also use the driver with the SH architecture.
You can of course do some mixed DT and platform device support on a board-level, but I don't really see what would be good about it. Actually, I believe that will just make things overly complicated without giving us the possibility to try out certain experimental features with platform-device-only interface.
Of course Simon, if you prefer to follow your proposal above then go ahead. However, please consider the case when this code will be back ported to LTSI-3.4.
Thanks,
/ magnus
PATCH v4 2/3 ARM: mach-shmobile: r8a7779: add SATA support
Quoted 32 lines · Magnus Damm
Hi Simon
Quoted 18 lines · Simon Horman
Quoted 10 lines · Olof Johansson
Quoted 4 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add SATA clock for r8a7779 SoC (for both device tree and usual cases). Register SATA controller as a "late" platform device on r8a7779 SoC.
Hi,
If you have the a binding in the device tree (which you do through patch 1/3), then there's no reason to have a platform device for it.
Hi Olof,
the DT exists but currently the marzen board brings up all of its devices using platform devices. Which if nothing else is internally consistent.
Quoted 8 lines
I suppose it would be possible to add a call to
r8a7779_add_standard_devices_dt()and have the board bring up this device using DT and the rest using platform drivers (until the drivers are migrated to DT).Would that be your preferred option?
Magnus, how do you feel about this idea?
I fail to see the upside I'm afraid.
Quoted 8 lines
I believe the best way forward is for us to keep on following the same style as we have done so far. So for drivers they should begin by interfacing as regular platform devices drivers and then add DT support incrementally. This allows us to try out things in a non-ABI kind of way and it also allows us to add support for various hardware feature that do not yet support DT like in the case of DMA Engine. With platform devices we can also use the driver with the SH architecture.
Sure, but in this case the DT bindings are set (by virtue of having been merged) and it is my understanding that they offer the same features as the platform device.
As it is a new device driver I lean towards Olof's suggestion.
Quoted 5 lines
You can of course do some mixed DT and platform device support on a board-level, but I don't really see what would be good about it. Actually, I believe that will just make things overly complicated without giving us the possibility to try out certain experimental features with platform-device-only interface.
I think that what would be good about it is:
* The DT code would be exercised by people using the default board file.
* The platform device would not need to be added.
Quoted 3 lines
Of course Simon, if you prefer to follow your proposal above then go ahead. However, please consider the case when this code will be back ported to LTSI-3.4.
With regards to backporting, the platform driver patch still exists (e.g. on the ML) so it can be used for backporting as needed.
PATCH v4 2/3 ARM: mach-shmobile: r8a7779: add SATA support
Quoted 54 lines · Simon Horman
Quoted 32 lines · Magnus Damm
Hi Simon
Quoted 18 lines · Simon Horman
Quoted 10 lines · Olof Johansson
Quoted 4 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add SATA clock for r8a7779 SoC (for both device tree and usual cases). Register SATA controller as a "late" platform device on r8a7779 SoC.
Hi,
If you have the a binding in the device tree (which you do through patch 1/3), then there's no reason to have a platform device for it.
Hi Olof,
the DT exists but currently the marzen board brings up all of its devices using platform devices. Which if nothing else is internally consistent.
Quoted 8 lines
I suppose it would be possible to add a call to
r8a7779_add_standard_devices_dt()and have the board bring up this device using DT and the rest using platform drivers (until the drivers are migrated to DT).Would that be your preferred option?
Magnus, how do you feel about this idea?
I fail to see the upside I'm afraid.
Quoted 8 lines
I believe the best way forward is for us to keep on following the same style as we have done so far. So for drivers they should begin by interfacing as regular platform devices drivers and then add DT support incrementally. This allows us to try out things in a non-ABI kind of way and it also allows us to add support for various hardware feature that do not yet support DT like in the case of DMA Engine. With platform devices we can also use the driver with the SH architecture.
Sure, but in this case the DT bindings are set (by virtue of having been merged) and it is my understanding that they offer the same features as the platform device.
As it is a new device driver I lean towards Olof's suggestion.
Quoted 5 lines
You can of course do some mixed DT and platform device support on a board-level, but I don't really see what would be good about it. Actually, I believe that will just make things overly complicated without giving us the possibility to try out certain experimental features with platform-device-only interface.
Quoted 4 lines
I think that what would be good about it is:
* The DT code would be exercised by people using the default board file.
* The platform device would not need to be added.
Right, and just to clarify: The driver is still a platform driver. For non-trivial devices with per-device data, there will be a function in the platform driver to fill in the platform data from the device tree contents.
So besides that one function, the rest of the driver can be shared between shmobile and arch/sh, there just won't be a platform_device registered on the ARM side.
-Olof
PATCH v4 2/3 ARM: mach-shmobile: r8a7779: add SATA support
In reply to Simon HormanQuoted 42 lines · Simon Horman
Quoted 32 lines · Magnus Damm
Hi Simon
Quoted 18 lines · Simon Horman
Quoted 10 lines · Olof Johansson
Quoted 4 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add SATA clock for r8a7779 SoC (for both device tree and usual cases). Register SATA controller as a "late" platform device on r8a7779 SoC.
Hi,
If you have the a binding in the device tree (which you do through patch 1/3), then there's no reason to have a platform device for it.
Hi Olof,
the DT exists but currently the marzen board brings up all of its devices using platform devices. Which if nothing else is internally consistent.
Quoted 8 lines
I suppose it would be possible to add a call to
r8a7779_add_standard_devices_dt()and have the board bring up this device using DT and the rest using platform drivers (until the drivers are migrated to DT).Would that be your preferred option?
Magnus, how do you feel about this idea?
I fail to see the upside I'm afraid.
Quoted 8 lines
I believe the best way forward is for us to keep on following the same style as we have done so far. So for drivers they should begin by interfacing as regular platform devices drivers and then add DT support incrementally. This allows us to try out things in a non-ABI kind of way and it also allows us to add support for various hardware feature that do not yet support DT like in the case of DMA Engine. With platform devices we can also use the driver with the SH architecture.
Quoted 3 lines
Sure, but in this case the DT bindings are set (by virtue of having been merged) and it is my understanding that they offer the same features as the platform device.
And if we want to add an experimental feature, how do you suggest we proceed?
Quoted 8 lines
As it is a new device driver I lean towards Olof's suggestion.
Quoted 5 lines
You can of course do some mixed DT and platform device support on a board-level, but I don't really see what would be good about it. Actually, I believe that will just make things overly complicated without giving us the possibility to try out certain experimental features with platform-device-only interface.
Quoted 4 lines
I think that what would be good about it is:
* The DT code would be exercised by people using the default board file.
* The platform device would not need to be added.
Sure. It is however just a couple of lines of data. Also, this bypasses the idea of the -reference boards, but hey.
Quoted 6 lines
Quoted 3 lines
Of course Simon, if you prefer to follow your proposal above then go ahead. However, please consider the case when this code will be back ported to LTSI-3.4.
With regards to backporting, the platform driver patch still exists (e.g. on the ML) so it can be used for backporting as needed.
And then there will be different code paths in the back port and in the upstream code.
Well, well.
Thanks,
/ magnus
PATCH v4 2/3 ARM: mach-shmobile: r8a7779: add SATA support
Quoted 43 lines · Magnus Damm
Quoted 42 lines · Simon Horman
Quoted 40 lines · Magnus Damm
Hi Simon
Quoted 18 lines · Simon Horman
Quoted 10 lines · Olof Johansson
Quoted 4 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add SATA clock for r8a7779 SoC (for both device tree and usual cases). Register SATA controller as a "late" platform device on r8a7779 SoC.
Hi,
If you have the a binding in the device tree (which you do through patch 1/3), then there's no reason to have a platform device for it.
Hi Olof,
the DT exists but currently the marzen board brings up all of its devices using platform devices. Which if nothing else is internally consistent.
Quoted 8 lines
I suppose it would be possible to add a call to
r8a7779_add_standard_devices_dt()and have the board bring up this device using DT and the rest using platform drivers (until the drivers are migrated to DT).Would that be your preferred option?
Magnus, how do you feel about this idea?
I fail to see the upside I'm afraid.
I believe the best way forward is for us to keep on following the same style as we have done so far. So for drivers they should begin by interfacing as regular platform devices drivers and then add DT support incrementally. This allows us to try out things in a non-ABI kind of way and it also allows us to add support for various hardware feature that do not yet support DT like in the case of DMA Engine. With platform devices we can also use the driver with the SH architecture.
Quoted 5 lines
Quoted 3 lines
Sure, but in this case the DT bindings are set (by virtue of having been merged) and it is my understanding that they offer the same features as the platform device.
And if we want to add an experimental feature, how do you suggest we proceed?
I wonder if this is a general problem for all drivers that are initialised via DT. I wonder how they add experimental features without setting bindings in stone.
Quoted 20 lines
Quoted 8 lines
As it is a new device driver I lean towards Olof's suggestion.
Quoted 5 lines
You can of course do some mixed DT and platform device support on a board-level, but I don't really see what would be good about it. Actually, I believe that will just make things overly complicated without giving us the possibility to try out certain experimental features with platform-device-only interface.
Quoted 4 lines
I think that what would be good about it is:
* The DT code would be exercised by people using the default board file.
* The platform device would not need to be added.Sure. It is however just a couple of lines of data. Also, this bypasses the idea of the -reference boards, but hey.
Quoted 4 lines
Quoted 3 lines
Of course Simon, if you prefer to follow your proposal above then go ahead. However, please consider the case when this code will be back ported to LTSI-3.4.
Quoted 5 lines
Quoted 2 lines
With regards to backporting, the platform driver patch still exists (e.g. on the ML) so it can be used for backporting as needed.
And then there will be different code paths in the back port and in the upstream code.
As you say, its only a few lines of code.
Quoted 1 line
From my point of view I think it would be sane to use DT for initialisation
where we can do so without losing functionality.
However, with all that said. I do accept that this would be a departure from how shmobile has handled things up until now. And that it is probably something that needs to be well thought through. So with that in mind I now plan to merge this patch. The code can be removed it later if appropriate.