2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Platform device support for Au1x00 SoCs.
|
|
|
|
*
|
|
|
|
* Copyright 2004, Matt Porter <mporter@kernel.crashing.org>
|
|
|
|
*
|
2008-04-03 20:02:53 +00:00
|
|
|
* (C) Copyright Embedded Alley Solutions, Inc 2005
|
|
|
|
* Author: Pantelis Antoniou <pantelis@embeddedalley.com>
|
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* This file is licensed under the terms of the GNU General Public
|
|
|
|
* License version 2. This program is licensed "as is" without any
|
|
|
|
* warranty of any kind, whether express or implied.
|
|
|
|
*/
|
2008-04-23 18:43:55 +00:00
|
|
|
|
2014-07-23 14:36:49 +00:00
|
|
|
#include <linux/clk.h>
|
2008-07-15 17:44:29 +00:00
|
|
|
#include <linux/dma-mapping.h>
|
2010-07-21 12:30:50 +00:00
|
|
|
#include <linux/etherdevice.h>
|
2011-05-08 08:42:18 +00:00
|
|
|
#include <linux/init.h>
|
2005-10-29 18:07:23 +00:00
|
|
|
#include <linux/platform_device.h>
|
2008-04-03 20:02:53 +00:00
|
|
|
#include <linux/serial_8250.h>
|
2011-05-08 08:42:18 +00:00
|
|
|
#include <linux/slab.h>
|
2012-10-08 13:11:22 +00:00
|
|
|
#include <linux/usb/ehci_pdriver.h>
|
2012-10-08 13:11:38 +00:00
|
|
|
#include <linux/usb/ohci_pdriver.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-08-12 09:39:43 +00:00
|
|
|
#include <asm/mach-au1x00/au1000.h>
|
2008-10-21 06:59:14 +00:00
|
|
|
#include <asm/mach-au1x00/au1xxx_dbdma.h>
|
|
|
|
#include <asm/mach-au1x00/au1100_mmc.h>
|
2009-11-10 00:13:30 +00:00
|
|
|
#include <asm/mach-au1x00/au1xxx_eth.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-07-21 12:30:50 +00:00
|
|
|
#include <prom.h>
|
|
|
|
|
2010-09-25 13:13:46 +00:00
|
|
|
static void alchemy_8250_pm(struct uart_port *port, unsigned int state,
|
|
|
|
unsigned int old_state)
|
|
|
|
{
|
2010-10-25 16:44:11 +00:00
|
|
|
#ifdef CONFIG_SERIAL_8250
|
2010-09-25 13:13:46 +00:00
|
|
|
switch (state) {
|
|
|
|
case 0:
|
2011-05-08 08:42:17 +00:00
|
|
|
alchemy_uart_enable(CPHYSADDR(port->membase));
|
2010-09-25 13:13:46 +00:00
|
|
|
serial8250_do_pm(port, state, old_state);
|
|
|
|
break;
|
|
|
|
case 3: /* power off */
|
|
|
|
serial8250_do_pm(port, state, old_state);
|
2011-05-08 08:42:17 +00:00
|
|
|
alchemy_uart_disable(CPHYSADDR(port->membase));
|
2010-09-25 13:13:46 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
serial8250_do_pm(port, state, old_state);
|
|
|
|
break;
|
|
|
|
}
|
2010-10-25 16:44:11 +00:00
|
|
|
#endif
|
2010-09-25 13:13:46 +00:00
|
|
|
}
|
|
|
|
|
2009-10-15 17:07:34 +00:00
|
|
|
#define PORT(_base, _irq) \
|
|
|
|
{ \
|
|
|
|
.mapbase = _base, \
|
|
|
|
.irq = _irq, \
|
|
|
|
.regshift = 2, \
|
|
|
|
.iotype = UPIO_AU, \
|
2013-01-22 11:59:30 +00:00
|
|
|
.flags = UPF_SKIP_TEST | UPF_IOREMAP | \
|
2009-10-28 20:49:46 +00:00
|
|
|
UPF_FIXED_TYPE, \
|
|
|
|
.type = PORT_16550A, \
|
2010-09-25 13:13:46 +00:00
|
|
|
.pm = alchemy_8250_pm, \
|
2008-04-03 20:02:53 +00:00
|
|
|
}
|
|
|
|
|
2011-05-08 08:42:17 +00:00
|
|
|
static struct plat_serial8250_port au1x00_uart_data[][4] __initdata = {
|
|
|
|
[ALCHEMY_CPU_AU1000] = {
|
|
|
|
PORT(AU1000_UART0_PHYS_ADDR, AU1000_UART0_INT),
|
|
|
|
PORT(AU1000_UART1_PHYS_ADDR, AU1000_UART1_INT),
|
|
|
|
PORT(AU1000_UART2_PHYS_ADDR, AU1000_UART2_INT),
|
|
|
|
PORT(AU1000_UART3_PHYS_ADDR, AU1000_UART3_INT),
|
|
|
|
},
|
|
|
|
[ALCHEMY_CPU_AU1500] = {
|
|
|
|
PORT(AU1000_UART0_PHYS_ADDR, AU1500_UART0_INT),
|
|
|
|
PORT(AU1000_UART3_PHYS_ADDR, AU1500_UART3_INT),
|
|
|
|
},
|
|
|
|
[ALCHEMY_CPU_AU1100] = {
|
|
|
|
PORT(AU1000_UART0_PHYS_ADDR, AU1100_UART0_INT),
|
|
|
|
PORT(AU1000_UART1_PHYS_ADDR, AU1100_UART1_INT),
|
|
|
|
PORT(AU1000_UART3_PHYS_ADDR, AU1100_UART3_INT),
|
|
|
|
},
|
|
|
|
[ALCHEMY_CPU_AU1550] = {
|
|
|
|
PORT(AU1000_UART0_PHYS_ADDR, AU1550_UART0_INT),
|
|
|
|
PORT(AU1000_UART1_PHYS_ADDR, AU1550_UART1_INT),
|
|
|
|
PORT(AU1000_UART3_PHYS_ADDR, AU1550_UART3_INT),
|
|
|
|
},
|
|
|
|
[ALCHEMY_CPU_AU1200] = {
|
|
|
|
PORT(AU1000_UART0_PHYS_ADDR, AU1200_UART0_INT),
|
|
|
|
PORT(AU1000_UART1_PHYS_ADDR, AU1200_UART1_INT),
|
|
|
|
},
|
2011-11-01 19:03:30 +00:00
|
|
|
[ALCHEMY_CPU_AU1300] = {
|
|
|
|
PORT(AU1300_UART0_PHYS_ADDR, AU1300_UART0_INT),
|
|
|
|
PORT(AU1300_UART1_PHYS_ADDR, AU1300_UART1_INT),
|
|
|
|
PORT(AU1300_UART2_PHYS_ADDR, AU1300_UART2_INT),
|
|
|
|
PORT(AU1300_UART3_PHYS_ADDR, AU1300_UART3_INT),
|
|
|
|
},
|
2008-04-03 20:02:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device au1xx0_uart_device = {
|
|
|
|
.name = "serial8250",
|
|
|
|
.id = PLAT8250_DEV_AU1X00,
|
|
|
|
};
|
|
|
|
|
2011-05-08 08:42:17 +00:00
|
|
|
static void __init alchemy_setup_uarts(int ctype)
|
|
|
|
{
|
2014-07-23 14:36:49 +00:00
|
|
|
long uartclk;
|
2011-05-08 08:42:17 +00:00
|
|
|
int s = sizeof(struct plat_serial8250_port);
|
|
|
|
int c = alchemy_get_uarts(ctype);
|
|
|
|
struct plat_serial8250_port *ports;
|
2014-07-23 14:36:49 +00:00
|
|
|
struct clk *clk = clk_get(NULL, ALCHEMY_PERIPH_CLK);
|
|
|
|
|
|
|
|
if (IS_ERR(clk))
|
|
|
|
return;
|
|
|
|
if (clk_prepare_enable(clk)) {
|
|
|
|
clk_put(clk);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
uartclk = clk_get_rate(clk);
|
|
|
|
clk_put(clk);
|
2011-05-08 08:42:17 +00:00
|
|
|
|
|
|
|
ports = kzalloc(s * (c + 1), GFP_KERNEL);
|
|
|
|
if (!ports) {
|
|
|
|
printk(KERN_INFO "Alchemy: no memory for UART data\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memcpy(ports, au1x00_uart_data[ctype], s * c);
|
|
|
|
au1xx0_uart_device.dev.platform_data = ports;
|
|
|
|
|
|
|
|
/* Fill up uartclk. */
|
|
|
|
for (s = 0; s < c; s++)
|
|
|
|
ports[s].uartclk = uartclk;
|
|
|
|
if (platform_device_register(&au1xx0_uart_device))
|
|
|
|
printk(KERN_INFO "Alchemy: failed to register UARTs\n");
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-08-12 09:39:39 +00:00
|
|
|
/* The dmamask must be set for OHCI/EHCI to work */
|
|
|
|
static u64 alchemy_ohci_dmamask = DMA_BIT_MASK(32);
|
|
|
|
static u64 __maybe_unused alchemy_ehci_dmamask = DMA_BIT_MASK(32);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-10-08 13:11:22 +00:00
|
|
|
/* Power on callback for the ehci platform driver */
|
|
|
|
static int alchemy_ehci_power_on(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
return alchemy_usb_control(ALCHEMY_USB_EHCI0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Power off/suspend callback for the ehci platform driver */
|
|
|
|
static void alchemy_ehci_power_off(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
alchemy_usb_control(ALCHEMY_USB_EHCI0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct usb_ehci_pdata alchemy_ehci_pdata = {
|
2013-01-22 11:59:30 +00:00
|
|
|
.no_io_watchdog = 1,
|
2012-10-08 13:11:22 +00:00
|
|
|
.power_on = alchemy_ehci_power_on,
|
|
|
|
.power_off = alchemy_ehci_power_off,
|
|
|
|
.power_suspend = alchemy_ehci_power_off,
|
|
|
|
};
|
|
|
|
|
2012-10-08 13:11:38 +00:00
|
|
|
/* Power on callback for the ohci platform driver */
|
|
|
|
static int alchemy_ohci_power_on(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
int unit;
|
|
|
|
|
|
|
|
unit = (pdev->id == 1) ?
|
|
|
|
ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0;
|
|
|
|
|
|
|
|
return alchemy_usb_control(unit, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Power off/suspend callback for the ohci platform driver */
|
|
|
|
static void alchemy_ohci_power_off(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
int unit;
|
|
|
|
|
|
|
|
unit = (pdev->id == 1) ?
|
|
|
|
ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0;
|
|
|
|
|
|
|
|
alchemy_usb_control(unit, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct usb_ohci_pdata alchemy_ohci_pdata = {
|
|
|
|
.power_on = alchemy_ohci_power_on,
|
|
|
|
.power_off = alchemy_ohci_power_off,
|
|
|
|
.power_suspend = alchemy_ohci_power_off,
|
|
|
|
};
|
|
|
|
|
2011-08-12 09:39:39 +00:00
|
|
|
static unsigned long alchemy_ohci_data[][2] __initdata = {
|
|
|
|
[ALCHEMY_CPU_AU1000] = { AU1000_USB_OHCI_PHYS_ADDR, AU1000_USB_HOST_INT },
|
|
|
|
[ALCHEMY_CPU_AU1500] = { AU1000_USB_OHCI_PHYS_ADDR, AU1500_USB_HOST_INT },
|
|
|
|
[ALCHEMY_CPU_AU1100] = { AU1000_USB_OHCI_PHYS_ADDR, AU1100_USB_HOST_INT },
|
|
|
|
[ALCHEMY_CPU_AU1550] = { AU1550_USB_OHCI_PHYS_ADDR, AU1550_USB_HOST_INT },
|
|
|
|
[ALCHEMY_CPU_AU1200] = { AU1200_USB_OHCI_PHYS_ADDR, AU1200_USB_INT },
|
2011-11-01 19:03:30 +00:00
|
|
|
[ALCHEMY_CPU_AU1300] = { AU1300_USB_OHCI0_PHYS_ADDR, AU1300_USB_INT },
|
2011-08-12 09:39:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned long alchemy_ehci_data[][2] __initdata = {
|
|
|
|
[ALCHEMY_CPU_AU1200] = { AU1200_USB_EHCI_PHYS_ADDR, AU1200_USB_INT },
|
2011-11-01 19:03:30 +00:00
|
|
|
[ALCHEMY_CPU_AU1300] = { AU1300_USB_EHCI_PHYS_ADDR, AU1300_USB_INT },
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2011-08-12 09:39:39 +00:00
|
|
|
static int __init _new_usbres(struct resource **r, struct platform_device **d)
|
|
|
|
{
|
|
|
|
*r = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
|
|
|
|
if (!*r)
|
|
|
|
return -ENOMEM;
|
|
|
|
*d = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
|
|
|
|
if (!*d) {
|
|
|
|
kfree(*r);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*d)->dev.coherent_dma_mask = DMA_BIT_MASK(32);
|
|
|
|
(*d)->num_resources = 2;
|
|
|
|
(*d)->resource = *r;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init alchemy_setup_usb(int ctype)
|
|
|
|
{
|
|
|
|
struct resource *res;
|
|
|
|
struct platform_device *pdev;
|
|
|
|
|
|
|
|
/* setup OHCI0. Every variant has one */
|
|
|
|
if (_new_usbres(&res, &pdev))
|
|
|
|
return;
|
|
|
|
|
|
|
|
res[0].start = alchemy_ohci_data[ctype][0];
|
|
|
|
res[0].end = res[0].start + 0x100 - 1;
|
|
|
|
res[0].flags = IORESOURCE_MEM;
|
|
|
|
res[1].start = alchemy_ohci_data[ctype][1];
|
|
|
|
res[1].end = res[1].start;
|
|
|
|
res[1].flags = IORESOURCE_IRQ;
|
2012-10-08 13:11:38 +00:00
|
|
|
pdev->name = "ohci-platform";
|
2011-08-12 09:39:39 +00:00
|
|
|
pdev->id = 0;
|
|
|
|
pdev->dev.dma_mask = &alchemy_ohci_dmamask;
|
2012-10-08 13:11:38 +00:00
|
|
|
pdev->dev.platform_data = &alchemy_ohci_pdata;
|
2011-08-12 09:39:39 +00:00
|
|
|
|
|
|
|
if (platform_device_register(pdev))
|
|
|
|
printk(KERN_INFO "Alchemy USB: cannot add OHCI0\n");
|
|
|
|
|
|
|
|
|
2011-11-01 19:03:30 +00:00
|
|
|
/* setup EHCI0: Au1200/Au1300 */
|
|
|
|
if ((ctype == ALCHEMY_CPU_AU1200) || (ctype == ALCHEMY_CPU_AU1300)) {
|
2011-08-12 09:39:39 +00:00
|
|
|
if (_new_usbres(&res, &pdev))
|
|
|
|
return;
|
|
|
|
|
|
|
|
res[0].start = alchemy_ehci_data[ctype][0];
|
|
|
|
res[0].end = res[0].start + 0x100 - 1;
|
|
|
|
res[0].flags = IORESOURCE_MEM;
|
|
|
|
res[1].start = alchemy_ehci_data[ctype][1];
|
|
|
|
res[1].end = res[1].start;
|
|
|
|
res[1].flags = IORESOURCE_IRQ;
|
2012-10-08 13:11:22 +00:00
|
|
|
pdev->name = "ehci-platform";
|
2011-08-12 09:39:39 +00:00
|
|
|
pdev->id = 0;
|
|
|
|
pdev->dev.dma_mask = &alchemy_ehci_dmamask;
|
2012-10-08 13:11:22 +00:00
|
|
|
pdev->dev.platform_data = &alchemy_ehci_pdata;
|
2011-08-12 09:39:39 +00:00
|
|
|
|
|
|
|
if (platform_device_register(pdev))
|
|
|
|
printk(KERN_INFO "Alchemy USB: cannot add EHCI0\n");
|
|
|
|
}
|
2011-11-01 19:03:30 +00:00
|
|
|
|
|
|
|
/* Au1300: OHCI1 */
|
|
|
|
if (ctype == ALCHEMY_CPU_AU1300) {
|
|
|
|
if (_new_usbres(&res, &pdev))
|
|
|
|
return;
|
|
|
|
|
|
|
|
res[0].start = AU1300_USB_OHCI1_PHYS_ADDR;
|
|
|
|
res[0].end = res[0].start + 0x100 - 1;
|
|
|
|
res[0].flags = IORESOURCE_MEM;
|
|
|
|
res[1].start = AU1300_USB_INT;
|
|
|
|
res[1].end = res[1].start;
|
|
|
|
res[1].flags = IORESOURCE_IRQ;
|
2012-10-08 13:11:38 +00:00
|
|
|
pdev->name = "ohci-platform";
|
2011-11-01 19:03:30 +00:00
|
|
|
pdev->id = 1;
|
|
|
|
pdev->dev.dma_mask = &alchemy_ohci_dmamask;
|
2012-10-08 13:11:38 +00:00
|
|
|
pdev->dev.platform_data = &alchemy_ohci_pdata;
|
2011-11-01 19:03:30 +00:00
|
|
|
|
|
|
|
if (platform_device_register(pdev))
|
|
|
|
printk(KERN_INFO "Alchemy USB: cannot add OHCI1\n");
|
|
|
|
}
|
2011-08-12 09:39:39 +00:00
|
|
|
}
|
|
|
|
|
2009-11-10 00:13:30 +00:00
|
|
|
/* Macro to help defining the Ethernet MAC resources */
|
2011-08-02 17:50:57 +00:00
|
|
|
#define MAC_RES_COUNT 4 /* MAC regs, MAC en, MAC INT, MACDMA regs */
|
|
|
|
#define MAC_RES(_base, _enable, _irq, _macdma) \
|
2009-11-10 00:13:30 +00:00
|
|
|
{ \
|
2011-05-08 08:42:18 +00:00
|
|
|
.start = _base, \
|
|
|
|
.end = _base + 0xffff, \
|
2009-11-10 00:13:30 +00:00
|
|
|
.flags = IORESOURCE_MEM, \
|
|
|
|
}, \
|
|
|
|
{ \
|
2011-05-08 08:42:18 +00:00
|
|
|
.start = _enable, \
|
|
|
|
.end = _enable + 0x3, \
|
2009-11-10 00:13:30 +00:00
|
|
|
.flags = IORESOURCE_MEM, \
|
|
|
|
}, \
|
|
|
|
{ \
|
|
|
|
.start = _irq, \
|
|
|
|
.end = _irq, \
|
|
|
|
.flags = IORESOURCE_IRQ \
|
2011-08-02 17:50:57 +00:00
|
|
|
}, \
|
|
|
|
{ \
|
|
|
|
.start = _macdma, \
|
|
|
|
.end = _macdma + 0x1ff, \
|
|
|
|
.flags = IORESOURCE_MEM, \
|
2009-11-10 00:13:30 +00:00
|
|
|
}
|
|
|
|
|
2011-05-08 08:42:18 +00:00
|
|
|
static struct resource au1xxx_eth0_resources[][MAC_RES_COUNT] __initdata = {
|
|
|
|
[ALCHEMY_CPU_AU1000] = {
|
|
|
|
MAC_RES(AU1000_MAC0_PHYS_ADDR,
|
|
|
|
AU1000_MACEN_PHYS_ADDR,
|
2011-08-02 17:50:57 +00:00
|
|
|
AU1000_MAC0_DMA_INT,
|
|
|
|
AU1000_MACDMA0_PHYS_ADDR)
|
2011-05-08 08:42:18 +00:00
|
|
|
},
|
|
|
|
[ALCHEMY_CPU_AU1500] = {
|
|
|
|
MAC_RES(AU1500_MAC0_PHYS_ADDR,
|
|
|
|
AU1500_MACEN_PHYS_ADDR,
|
2011-08-02 17:50:57 +00:00
|
|
|
AU1500_MAC0_DMA_INT,
|
|
|
|
AU1000_MACDMA0_PHYS_ADDR)
|
2011-05-08 08:42:18 +00:00
|
|
|
},
|
|
|
|
[ALCHEMY_CPU_AU1100] = {
|
|
|
|
MAC_RES(AU1000_MAC0_PHYS_ADDR,
|
|
|
|
AU1000_MACEN_PHYS_ADDR,
|
2011-08-02 17:50:57 +00:00
|
|
|
AU1100_MAC0_DMA_INT,
|
|
|
|
AU1000_MACDMA0_PHYS_ADDR)
|
2011-05-08 08:42:18 +00:00
|
|
|
},
|
|
|
|
[ALCHEMY_CPU_AU1550] = {
|
|
|
|
MAC_RES(AU1000_MAC0_PHYS_ADDR,
|
|
|
|
AU1000_MACEN_PHYS_ADDR,
|
2011-08-02 17:50:57 +00:00
|
|
|
AU1550_MAC0_DMA_INT,
|
|
|
|
AU1000_MACDMA0_PHYS_ADDR)
|
2011-05-08 08:42:18 +00:00
|
|
|
},
|
2009-11-10 00:13:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct au1000_eth_platform_data au1xxx_eth0_platform_data = {
|
|
|
|
.phy1_search_mac0 = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device au1xxx_eth0_device = {
|
|
|
|
.name = "au1000-eth",
|
|
|
|
.id = 0,
|
2011-05-08 08:42:18 +00:00
|
|
|
.num_resources = MAC_RES_COUNT,
|
2009-11-10 00:13:30 +00:00
|
|
|
.dev.platform_data = &au1xxx_eth0_platform_data,
|
|
|
|
};
|
|
|
|
|
2011-05-08 08:42:18 +00:00
|
|
|
static struct resource au1xxx_eth1_resources[][MAC_RES_COUNT] __initdata = {
|
|
|
|
[ALCHEMY_CPU_AU1000] = {
|
|
|
|
MAC_RES(AU1000_MAC1_PHYS_ADDR,
|
|
|
|
AU1000_MACEN_PHYS_ADDR + 4,
|
2011-08-02 17:50:57 +00:00
|
|
|
AU1000_MAC1_DMA_INT,
|
|
|
|
AU1000_MACDMA1_PHYS_ADDR)
|
2011-05-08 08:42:18 +00:00
|
|
|
},
|
|
|
|
[ALCHEMY_CPU_AU1500] = {
|
|
|
|
MAC_RES(AU1500_MAC1_PHYS_ADDR,
|
|
|
|
AU1500_MACEN_PHYS_ADDR + 4,
|
2011-08-02 17:50:57 +00:00
|
|
|
AU1500_MAC1_DMA_INT,
|
|
|
|
AU1000_MACDMA1_PHYS_ADDR)
|
2011-05-08 08:42:18 +00:00
|
|
|
},
|
|
|
|
[ALCHEMY_CPU_AU1550] = {
|
|
|
|
MAC_RES(AU1000_MAC1_PHYS_ADDR,
|
|
|
|
AU1000_MACEN_PHYS_ADDR + 4,
|
2011-08-02 17:50:57 +00:00
|
|
|
AU1550_MAC1_DMA_INT,
|
|
|
|
AU1000_MACDMA1_PHYS_ADDR)
|
2011-05-08 08:42:18 +00:00
|
|
|
},
|
2010-02-26 16:22:02 +00:00
|
|
|
};
|
|
|
|
|
2009-11-10 00:13:30 +00:00
|
|
|
static struct au1000_eth_platform_data au1xxx_eth1_platform_data = {
|
|
|
|
.phy1_search_mac0 = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device au1xxx_eth1_device = {
|
|
|
|
.name = "au1000-eth",
|
|
|
|
.id = 1,
|
2011-05-08 08:42:18 +00:00
|
|
|
.num_resources = MAC_RES_COUNT,
|
2009-11-10 00:13:30 +00:00
|
|
|
.dev.platform_data = &au1xxx_eth1_platform_data,
|
|
|
|
};
|
|
|
|
|
|
|
|
void __init au1xxx_override_eth_cfg(unsigned int port,
|
|
|
|
struct au1000_eth_platform_data *eth_data)
|
|
|
|
{
|
|
|
|
if (!eth_data || port > 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (port == 0)
|
|
|
|
memcpy(&au1xxx_eth0_platform_data, eth_data,
|
|
|
|
sizeof(struct au1000_eth_platform_data));
|
|
|
|
else
|
|
|
|
memcpy(&au1xxx_eth1_platform_data, eth_data,
|
|
|
|
sizeof(struct au1000_eth_platform_data));
|
2011-05-08 08:42:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __init alchemy_setup_macs(int ctype)
|
|
|
|
{
|
|
|
|
int ret, i;
|
|
|
|
unsigned char ethaddr[6];
|
|
|
|
struct resource *macres;
|
|
|
|
|
|
|
|
/* Handle 1st MAC */
|
|
|
|
if (alchemy_get_macs(ctype) < 1)
|
|
|
|
return;
|
|
|
|
|
2011-11-17 22:43:40 +00:00
|
|
|
macres = kmemdup(au1xxx_eth0_resources[ctype],
|
|
|
|
sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL);
|
2011-05-08 08:42:18 +00:00
|
|
|
if (!macres) {
|
|
|
|
printk(KERN_INFO "Alchemy: no memory for MAC0 resources\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
au1xxx_eth0_device.resource = macres;
|
|
|
|
|
|
|
|
i = prom_get_ethernet_addr(ethaddr);
|
|
|
|
if (!i && !is_valid_ether_addr(au1xxx_eth0_platform_data.mac))
|
|
|
|
memcpy(au1xxx_eth0_platform_data.mac, ethaddr, 6);
|
|
|
|
|
|
|
|
ret = platform_device_register(&au1xxx_eth0_device);
|
2011-08-02 13:50:56 +00:00
|
|
|
if (ret)
|
2011-05-08 08:42:18 +00:00
|
|
|
printk(KERN_INFO "Alchemy: failed to register MAC0\n");
|
|
|
|
|
|
|
|
|
|
|
|
/* Handle 2nd MAC */
|
|
|
|
if (alchemy_get_macs(ctype) < 2)
|
|
|
|
return;
|
|
|
|
|
2011-11-17 22:43:40 +00:00
|
|
|
macres = kmemdup(au1xxx_eth1_resources[ctype],
|
|
|
|
sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL);
|
2011-05-08 08:42:18 +00:00
|
|
|
if (!macres) {
|
|
|
|
printk(KERN_INFO "Alchemy: no memory for MAC1 resources\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
au1xxx_eth1_device.resource = macres;
|
|
|
|
|
|
|
|
ethaddr[5] += 1; /* next addr for 2nd MAC */
|
|
|
|
if (!i && !is_valid_ether_addr(au1xxx_eth1_platform_data.mac))
|
|
|
|
memcpy(au1xxx_eth1_platform_data.mac, ethaddr, 6);
|
|
|
|
|
|
|
|
/* Register second MAC if enabled in pinfunc */
|
2014-07-23 14:36:24 +00:00
|
|
|
if (!(alchemy_rdsys(AU1000_SYS_PINFUNC) & SYS_PF_NI2)) {
|
2011-05-08 08:42:18 +00:00
|
|
|
ret = platform_device_register(&au1xxx_eth1_device);
|
|
|
|
if (ret)
|
|
|
|
printk(KERN_INFO "Alchemy: failed to register MAC1\n");
|
|
|
|
}
|
2009-11-10 00:13:30 +00:00
|
|
|
}
|
|
|
|
|
2008-04-30 19:18:41 +00:00
|
|
|
static int __init au1xxx_platform_init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2011-08-12 09:39:45 +00:00
|
|
|
int ctype = alchemy_get_cputype();
|
2008-04-03 20:02:53 +00:00
|
|
|
|
2011-05-08 08:42:17 +00:00
|
|
|
alchemy_setup_uarts(ctype);
|
2011-05-08 08:42:18 +00:00
|
|
|
alchemy_setup_macs(ctype);
|
2011-08-12 09:39:39 +00:00
|
|
|
alchemy_setup_usb(ctype);
|
2010-07-21 12:30:50 +00:00
|
|
|
|
2011-08-12 09:39:45 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
arch_initcall(au1xxx_platform_init);
|