* [PATCH 1/4] alchemy: register au1000_eth as a platform driver part one
@ 2009-07-28 21:00 Florian Fainelli
2009-07-29 7:15 ` Manuel Lauss
0 siblings, 1 reply; 8+ messages in thread
From: Florian Fainelli @ 2009-07-28 21:00 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, Manuel Lauss
This is the first patch which registers au1000_eth as a platform
driver. Note that the second MAC (only on non-Au1100 SoC) is
dynamically registered if the interface is enabled in sys_pinfunc.
which also custom boards like Meshcube. PHY information is passed
to the driver in a follow-up patch.
Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c
index 117f99f..acc1ae2 100644
--- a/arch/mips/alchemy/common/platform.c
+++ b/arch/mips/alchemy/common/platform.c
@@ -331,6 +331,61 @@ static struct platform_device pbdb_smbus_device = {
};
#endif
+/* All Alchemy board have at least one Ethernet MAC */
+#define MAC_RES(_base, _enable, _irq) \
+ { \
+ .start = CPHYSADDR(_base), \
+ .end = CPHYSADDR(_base + 0xffff), \
+ .flags = IORESOURCE_MEM, \
+ }, \
+ { \
+ .start = CPHYSADDR(_enable), \
+ .end = CPHYSADDR(_enable + 0x4), \
+ .flags = IORESOURCE_MEM, \
+ }, \
+ { \
+ .start = _irq, \
+ .end = _irq, \
+ .flags = IORESOURCE_IRQ \
+ }
+
+static struct resource au1xxx_eth0_resources[] = {
+#if defined(CONFIG_SOC_AU1000)
+ MAC_RES(AU1000_ETH0_BASE, AU1000_MAC0_ENABLE, AU1000_MAC0_DMA_INT),
+#elif defined(CONFIG_SOC_AU1100)
+ MAC_RES(AU1100_ETH0_BASE, AU1100_MAC0_ENABLE, AU1100_MAC0_DMA_INT),
+#elif defined(CONFIG_SOC_AU1550)
+ MAC_RES(AU1550_ETH0_BASE, AU1550_MAC0_ENABLE, AU1550_MAC0_DMA_INT),
+#elif defined(CONFIG_SOC_AU1500)
+ MAC_RES(AU1500_ETH0_BASE, AU1500_MAC0_ENABLE, AU1500_MAC0_DMA_INT),
+#endif
+};
+static struct resource au1xxx_eth1_resources[] = {
+#if defined(CONFIG_SOC_AU1000)
+ MAC_RES(AU1000_ETH1_BASE, AU1000_MAC1_ENABLE, AU1000_MAC1_DMA_INT),
+#elif defined(CONFIG_SOC_AU1550)
+ MAC_RES(AU1550_ETH1_BASE, AU1550_MAC1_ENABLE, AU1550_MAC1_DMA_INT),
+#elif defined(CONFIG_SOC_AU1500)
+ MAC_RES(AU1500_ETH1_BASE, AU1500_MAC1_ENABLE, AU1500_MAC1_DMA_INT),
+#endif
+};
+
+static struct platform_device au1xxx_eth0_device = {
+ .name = "au1000-eth",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(au1xxx_eth0_resources),
+ .resource = au1xxx_eth0_resources,
+};
+
+#ifndef CONFIG_SOC_AU1100
+static struct platform_device au1xxx_eth1_device = {
+ .name = "au1000-eth",
+ .id = 1,
+ .num_resources = ARRAY_SIZE(au1xxx_eth1_resources),
+ .resource = au1xxx_eth1_resources,
+};
+#endif
+
static struct platform_device *au1xxx_platform_devices[] __initdata = {
&au1xx0_uart_device,
&au1xxx_usb_ohci_device,
@@ -351,17 +406,25 @@ static struct platform_device *au1xxx_platform_devices[] __initdata = {
#ifdef SMBUS_PSC_BASE
&pbdb_smbus_device,
#endif
+ &au1xxx_eth0_device,
};
static int __init au1xxx_platform_init(void)
{
unsigned int uartclk = get_au1x00_uart_baud_base() * 16;
- int i;
+ int i, ni;
/* Fill up uartclk. */
for (i = 0; au1x00_uart_data[i].flags; i++)
au1x00_uart_data[i].uartclk = uartclk;
+ /* Register second MAC if enabled in pinfunc */
+#ifndef CONFIG_SOC_AU1100
+ ni = (int)((au_readl(SYS_PINFUNC) & (u32)(SYS_PF_NI2)) >> 4);
+ if (!(ni + 1))
+ platform_device_register(&au1xxx_eth1_device);
+#endif
+
return platform_add_devices(au1xxx_platform_devices,
ARRAY_SIZE(au1xxx_platform_devices));
}
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 1/4] alchemy: register au1000_eth as a platform driver part one
2009-07-28 21:00 [PATCH 1/4] alchemy: register au1000_eth as a platform driver part one Florian Fainelli
@ 2009-07-29 7:15 ` Manuel Lauss
2009-07-29 7:15 ` Manuel Lauss
2009-07-29 8:10 ` Florian Fainelli
0 siblings, 2 replies; 8+ messages in thread
From: Manuel Lauss @ 2009-07-29 7:15 UTC (permalink / raw)
To: Florian Fainelli; +Cc: Ralf Baechle, linux-mips
Hi Florian,
On Tue, Jul 28, 2009 at 11:00 PM, Florian Fainelli<florian@openwrt.org> wrote:
> --- a/arch/mips/alchemy/common/platform.c
> +++ b/arch/mips/alchemy/common/platform.c
> @@ -331,6 +331,61 @@ static struct platform_device pbdb_smbus_device = {
> };
> #endif
>
> +/* All Alchemy board have at least one Ethernet MAC */
Au1200/1300 don't have a MAC (unfortunately, IMO).
> static int __init au1xxx_platform_init(void)
> {
> unsigned int uartclk = get_au1x00_uart_baud_base() * 16;
> - int i;
> + int i, ni;
>
> /* Fill up uartclk. */
> for (i = 0; au1x00_uart_data[i].flags; i++)
> au1x00_uart_data[i].uartclk = uartclk;
>
> + /* Register second MAC if enabled in pinfunc */
> +#ifndef CONFIG_SOC_AU1100
> + ni = (int)((au_readl(SYS_PINFUNC) & (u32)(SYS_PF_NI2)) >> 4);
> + if (!(ni + 1))
> + platform_device_register(&au1xxx_eth1_device);
> +#endif
> +
This won't work on Au1200/Au1300 since their SYS_PINFUNC register
has a different bit layout.
And you already know that I'm not very fond of alchemy/common/platform.c ;-)
I still think you should add appropriate MAC platform information to the boards
which actually use it.
Manuel Lauss
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 1/4] alchemy: register au1000_eth as a platform driver part one
2009-07-29 7:15 ` Manuel Lauss
@ 2009-07-29 7:15 ` Manuel Lauss
2009-07-29 8:10 ` Florian Fainelli
1 sibling, 0 replies; 8+ messages in thread
From: Manuel Lauss @ 2009-07-29 7:15 UTC (permalink / raw)
To: Florian Fainelli; +Cc: Ralf Baechle, linux-mips
Hi Florian,
On Tue, Jul 28, 2009 at 11:00 PM, Florian Fainelli<florian@openwrt.org> wrote:
> --- a/arch/mips/alchemy/common/platform.c
> +++ b/arch/mips/alchemy/common/platform.c
> @@ -331,6 +331,61 @@ static struct platform_device pbdb_smbus_device = {
> };
> #endif
>
> +/* All Alchemy board have at least one Ethernet MAC */
Au1200/1300 don't have a MAC (unfortunately, IMO).
> static int __init au1xxx_platform_init(void)
> {
> unsigned int uartclk = get_au1x00_uart_baud_base() * 16;
> - int i;
> + int i, ni;
>
> /* Fill up uartclk. */
> for (i = 0; au1x00_uart_data[i].flags; i++)
> au1x00_uart_data[i].uartclk = uartclk;
>
> + /* Register second MAC if enabled in pinfunc */
> +#ifndef CONFIG_SOC_AU1100
> + ni = (int)((au_readl(SYS_PINFUNC) & (u32)(SYS_PF_NI2)) >> 4);
> + if (!(ni + 1))
> + platform_device_register(&au1xxx_eth1_device);
> +#endif
> +
This won't work on Au1200/Au1300 since their SYS_PINFUNC register
has a different bit layout.
And you already know that I'm not very fond of alchemy/common/platform.c ;-)
I still think you should add appropriate MAC platform information to the boards
which actually use it.
Manuel Lauss
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 1/4] alchemy: register au1000_eth as a platform driver part one
2009-07-29 7:15 ` Manuel Lauss
2009-07-29 7:15 ` Manuel Lauss
@ 2009-07-29 8:10 ` Florian Fainelli
2009-07-29 13:41 ` Sergei Shtylyov
1 sibling, 1 reply; 8+ messages in thread
From: Florian Fainelli @ 2009-07-29 8:10 UTC (permalink / raw)
To: Manuel Lauss; +Cc: Ralf Baechle, linux-mips
Le Wednesday 29 July 2009 09:15:52 Manuel Lauss, vous avez écrit :
> Hi Florian,
>
> On Tue, Jul 28, 2009 at 11:00 PM, Florian Fainelli<florian@openwrt.org> wrote:
> > --- a/arch/mips/alchemy/common/platform.c
> > +++ b/arch/mips/alchemy/common/platform.c
> > @@ -331,6 +331,61 @@ static struct platform_device pbdb_smbus_device = {
> > };
> > #endif
> >
> > +/* All Alchemy board have at least one Ethernet MAC */
>
> Au1200/1300 don't have a MAC (unfortunately, IMO).
Right.
>
> > static int __init au1xxx_platform_init(void)
> > {
> > unsigned int uartclk = get_au1x00_uart_baud_base() * 16;
> > - int i;
> > + int i, ni;
> >
> > /* Fill up uartclk. */
> > for (i = 0; au1x00_uart_data[i].flags; i++)
> > au1x00_uart_data[i].uartclk = uartclk;
> >
> > + /* Register second MAC if enabled in pinfunc */
> > +#ifndef CONFIG_SOC_AU1100
> > + ni = (int)((au_readl(SYS_PINFUNC) & (u32)(SYS_PF_NI2)) >> 4);
> > + if (!(ni + 1))
> > + platform_device_register(&au1xxx_eth1_device);
> > +#endif
> > +
>
> This won't work on Au1200/Au1300 since their SYS_PINFUNC register
> has a different bit layout.
>
>
> And you already know that I'm not very fond of alchemy/common/platform.c
> ;-) I still think you should add appropriate MAC platform information to
> the boards which actually use it.
Yes I know ;) I was just wanting to get this out quickly before you kill platform.c
I will make the au1000-eth devices be registered on a per-board basis.
--
Best regards, Florian Fainelli
Email: florian@openwrt.org
Web: http://openwrt.org
IRC: [florian] on irc.freenode.net
-------------------------------
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 1/4] alchemy: register au1000_eth as a platform driver part one
2009-07-29 8:10 ` Florian Fainelli
@ 2009-07-29 13:41 ` Sergei Shtylyov
2009-07-29 14:27 ` Manuel Lauss
0 siblings, 1 reply; 8+ messages in thread
From: Sergei Shtylyov @ 2009-07-29 13:41 UTC (permalink / raw)
To: Florian Fainelli; +Cc: Manuel Lauss, Ralf Baechle, linux-mips
Hello.
Florian Fainelli wrote:
>>> static int __init au1xxx_platform_init(void)
>>> {
>>> unsigned int uartclk = get_au1x00_uart_baud_base() * 16;
>>>- int i;
>>>+ int i, ni;
>>>
>>> /* Fill up uartclk. */
>>> for (i = 0; au1x00_uart_data[i].flags; i++)
>>> au1x00_uart_data[i].uartclk = uartclk;
>>>
>>>+ /* Register second MAC if enabled in pinfunc */
>>>+#ifndef CONFIG_SOC_AU1100
>>>+ ni = (int)((au_readl(SYS_PINFUNC) & (u32)(SYS_PF_NI2)) >> 4);
>>>+ if (!(ni + 1))
>>>+ platform_device_register(&au1xxx_eth1_device);
>>>+#endif
>>>+
>>This won't work on Au1200/Au1300 since their SYS_PINFUNC register
>>has a different bit layout.
>>And you already know that I'm not very fond of alchemy/common/platform.c
>>;-) I still think you should add appropriate MAC platform information to
>>the boards which actually use it.
> Yes I know ;) I was just wanting to get this out quickly before you kill platform.c
I'd NAK such patch (and have already done so, AFAIR).
> I will make the au1000-eth devices be registered on a per-board basis.
Please don't. You can register them in platform.c, and yet leave
actually board specific platform data in the board files. There's no reason
to duplicate the platfrom device itself.
WBR, Sergei
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 1/4] alchemy: register au1000_eth as a platform driver part one
2009-07-29 13:41 ` Sergei Shtylyov
@ 2009-07-29 14:27 ` Manuel Lauss
2009-07-29 14:27 ` Manuel Lauss
2009-07-30 20:50 ` Florian Fainelli
0 siblings, 2 replies; 8+ messages in thread
From: Manuel Lauss @ 2009-07-29 14:27 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: Florian Fainelli, Ralf Baechle, linux-mips
Hi Sergei,
>> Yes I know ;) I was just wanting to get this out quickly before you kill
>> platform.c
>
> I'd NAK such patch (and have already done so, AFAIR).
I've already surrendered myself to the fact that I'll never be able to get rid
of this file in my lifetime. However I've set a timer on my mail machine to
send a patch (which I'll keep rebasing to latest sources) trying that again
in 80 years or so ;-)
>> I will make the au1000-eth devices be registered on a per-board basis.
>
> Please don't. You can register them in platform.c, and yet leave actually
> board specific platform data in the board files. There's no reason to
> duplicate the platfrom device itself.
Let's say I have 2 pieces of hardware, indentical in all things,
except one has an Au1100, and the other Au1500 (different MAC mmio
address and unit counts). I want to build a kernel which runs on both.
This can certainly be done, but the existence of common/platform.c and
your insistence on maintaining the status-quo limits me to one board
per kernel (theoretical example currently, i know).
I also dislike having to #ifdef around this file when a new platform
is introduced which doesn't need/use all devices registered in there!
(for example au1200 mmc platform data. Suppose I have a platform
which doesn't use mmc; I can either add a #ifdef for my new board or
provide empty platform data stubs in my board code. Both solutions
suck IMO; the former because then when I (and others) submit new
board code upstream common/platform.c will develop into a mess of
random #ifdefs (just look at common/reset.c!) and the latter because
platform data and -device registration are in different places in the
source tree.
Manuel Lauss
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/4] alchemy: register au1000_eth as a platform driver part one
2009-07-29 14:27 ` Manuel Lauss
@ 2009-07-29 14:27 ` Manuel Lauss
2009-07-30 20:50 ` Florian Fainelli
1 sibling, 0 replies; 8+ messages in thread
From: Manuel Lauss @ 2009-07-29 14:27 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: Florian Fainelli, Ralf Baechle, linux-mips
Hi Sergei,
>> Yes I know ;) I was just wanting to get this out quickly before you kill
>> platform.c
>
> I'd NAK such patch (and have already done so, AFAIR).
I've already surrendered myself to the fact that I'll never be able to get rid
of this file in my lifetime. However I've set a timer on my mail machine to
send a patch (which I'll keep rebasing to latest sources) trying that again
in 80 years or so ;-)
>> I will make the au1000-eth devices be registered on a per-board basis.
>
> Please don't. You can register them in platform.c, and yet leave actually
> board specific platform data in the board files. There's no reason to
> duplicate the platfrom device itself.
Let's say I have 2 pieces of hardware, indentical in all things,
except one has an Au1100, and the other Au1500 (different MAC mmio
address and unit counts). I want to build a kernel which runs on both.
This can certainly be done, but the existence of common/platform.c and
your insistence on maintaining the status-quo limits me to one board
per kernel (theoretical example currently, i know).
I also dislike having to #ifdef around this file when a new platform
is introduced which doesn't need/use all devices registered in there!
(for example au1200 mmc platform data. Suppose I have a platform
which doesn't use mmc; I can either add a #ifdef for my new board or
provide empty platform data stubs in my board code. Both solutions
suck IMO; the former because then when I (and others) submit new
board code upstream common/platform.c will develop into a mess of
random #ifdefs (just look at common/reset.c!) and the latter because
platform data and -device registration are in different places in the
source tree.
Manuel Lauss
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/4] alchemy: register au1000_eth as a platform driver part one
2009-07-29 14:27 ` Manuel Lauss
2009-07-29 14:27 ` Manuel Lauss
@ 2009-07-30 20:50 ` Florian Fainelli
1 sibling, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2009-07-30 20:50 UTC (permalink / raw)
To: Manuel Lauss; +Cc: Sergei Shtylyov, Ralf Baechle, linux-mips
Hi Manuel, Sergei,
Le Wednesday 29 July 2009 16:27:02 Manuel Lauss, vous avez écrit :
> Hi Sergei,
>
> >> Yes I know ;) I was just wanting to get this out quickly before you kill
> >> platform.c
> >
> > I'd NAK such patch (and have already done so, AFAIR).
>
> I've already surrendered myself to the fact that I'll never be able to get
> rid of this file in my lifetime. However I've set a timer on my mail
> machine to send a patch (which I'll keep rebasing to latest sources) trying
> that again in 80 years or so ;-)
>
> >> I will make the au1000-eth devices be registered on a per-board basis.
> >
> > Please don't. You can register them in platform.c, and yet leave
> > actually board specific platform data in the board files. There's no
> > reason to duplicate the platfrom device itself.
>
> Let's say I have 2 pieces of hardware, indentical in all things,
> except one has an Au1100, and the other Au1500 (different MAC mmio
> address and unit counts). I want to build a kernel which runs on both.
> This can certainly be done, but the existence of common/platform.c and
> your insistence on maintaining the status-quo limits me to one board
> per kernel (theoretical example currently, i know).
I am still a big fan of a single kernel approach for a SoC whenever runtime
identification is possible.
>
> I also dislike having to #ifdef around this file when a new platform
> is introduced which doesn't need/use all devices registered in there!
> (for example au1200 mmc platform data. Suppose I have a platform
> which doesn't use mmc; I can either add a #ifdef for my new board or
> provide empty platform data stubs in my board code. Both solutions
> suck IMO; the former because then when I (and others) submit new
> board code upstream common/platform.c will develop into a mess of
> random #ifdefs (just look at common/reset.c!) and the latter because
> platform data and -device registration are in different places in the
> source tree.
Well, right now, the au1000_eth driver has been converted in a way that even
passing no platform_data to it makes it pick the right defaults (searching
for PHY1 on MAC0) so this is not a big problem here, this might not be the
case with other drivers.
Even though it duplicates quite a lot of code, it's still cleaner when you
either have to pick up the eval board which is the closest to your design, or
have to add a new board.
I am going to respin the patches with the Ethernet driver registered in a
per-board platform.c file, which lets room for other platform devices to be
registered there too. Everyone can then make up his mid about which approach
he prefers ;)
--
Best regards, Florian Fainelli
Email: florian@openwrt.org
Web: http://openwrt.org
IRC: [florian] on irc.freenode.net
-------------------------------
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-07-30 20:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-28 21:00 [PATCH 1/4] alchemy: register au1000_eth as a platform driver part one Florian Fainelli
2009-07-29 7:15 ` Manuel Lauss
2009-07-29 7:15 ` Manuel Lauss
2009-07-29 8:10 ` Florian Fainelli
2009-07-29 13:41 ` Sergei Shtylyov
2009-07-29 14:27 ` Manuel Lauss
2009-07-29 14:27 ` Manuel Lauss
2009-07-30 20:50 ` Florian Fainelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).