30
31
#ifdef CONFIG_SERIAL_8250
33
if ((__raw_readl(port->membase + UART_MOD_CNTRL) & 3) != 3) {
34
/* power-on sequence as suggested in the databooks */
35
__raw_writel(0, port->membase + UART_MOD_CNTRL);
37
__raw_writel(1, port->membase + UART_MOD_CNTRL);
40
__raw_writel(3, port->membase + UART_MOD_CNTRL); /* full on */
34
alchemy_uart_enable(CPHYSADDR(port->membase));
42
35
serial8250_do_pm(port, state, old_state);
44
37
case 3: /* power off */
45
38
serial8250_do_pm(port, state, old_state);
46
__raw_writel(0, port->membase + UART_MOD_CNTRL);
39
alchemy_uart_disable(CPHYSADDR(port->membase));
50
42
serial8250_do_pm(port, state, old_state);
65
57
.pm = alchemy_8250_pm, \
68
static struct plat_serial8250_port au1x00_uart_data[] = {
69
#if defined(CONFIG_SOC_AU1000)
70
PORT(UART0_PHYS_ADDR, AU1000_UART0_INT),
71
PORT(UART1_PHYS_ADDR, AU1000_UART1_INT),
72
PORT(UART2_PHYS_ADDR, AU1000_UART2_INT),
73
PORT(UART3_PHYS_ADDR, AU1000_UART3_INT),
74
#elif defined(CONFIG_SOC_AU1500)
75
PORT(UART0_PHYS_ADDR, AU1500_UART0_INT),
76
PORT(UART3_PHYS_ADDR, AU1500_UART3_INT),
77
#elif defined(CONFIG_SOC_AU1100)
78
PORT(UART0_PHYS_ADDR, AU1100_UART0_INT),
79
PORT(UART1_PHYS_ADDR, AU1100_UART1_INT),
80
PORT(UART3_PHYS_ADDR, AU1100_UART3_INT),
81
#elif defined(CONFIG_SOC_AU1550)
82
PORT(UART0_PHYS_ADDR, AU1550_UART0_INT),
83
PORT(UART1_PHYS_ADDR, AU1550_UART1_INT),
84
PORT(UART3_PHYS_ADDR, AU1550_UART3_INT),
85
#elif defined(CONFIG_SOC_AU1200)
86
PORT(UART0_PHYS_ADDR, AU1200_UART0_INT),
87
PORT(UART1_PHYS_ADDR, AU1200_UART1_INT),
60
static struct plat_serial8250_port au1x00_uart_data[][4] __initdata = {
61
[ALCHEMY_CPU_AU1000] = {
62
PORT(AU1000_UART0_PHYS_ADDR, AU1000_UART0_INT),
63
PORT(AU1000_UART1_PHYS_ADDR, AU1000_UART1_INT),
64
PORT(AU1000_UART2_PHYS_ADDR, AU1000_UART2_INT),
65
PORT(AU1000_UART3_PHYS_ADDR, AU1000_UART3_INT),
67
[ALCHEMY_CPU_AU1500] = {
68
PORT(AU1000_UART0_PHYS_ADDR, AU1500_UART0_INT),
69
PORT(AU1000_UART3_PHYS_ADDR, AU1500_UART3_INT),
71
[ALCHEMY_CPU_AU1100] = {
72
PORT(AU1000_UART0_PHYS_ADDR, AU1100_UART0_INT),
73
PORT(AU1000_UART1_PHYS_ADDR, AU1100_UART1_INT),
74
PORT(AU1000_UART3_PHYS_ADDR, AU1100_UART3_INT),
76
[ALCHEMY_CPU_AU1550] = {
77
PORT(AU1000_UART0_PHYS_ADDR, AU1550_UART0_INT),
78
PORT(AU1000_UART1_PHYS_ADDR, AU1550_UART1_INT),
79
PORT(AU1000_UART3_PHYS_ADDR, AU1550_UART3_INT),
81
[ALCHEMY_CPU_AU1200] = {
82
PORT(AU1000_UART0_PHYS_ADDR, AU1200_UART0_INT),
83
PORT(AU1000_UART1_PHYS_ADDR, AU1200_UART1_INT),
92
87
static struct platform_device au1xx0_uart_device = {
93
88
.name = "serial8250",
94
89
.id = PLAT8250_DEV_AU1X00,
96
.platform_data = au1x00_uart_data,
92
static void __init alchemy_setup_uarts(int ctype)
94
unsigned int uartclk = get_au1x00_uart_baud_base() * 16;
95
int s = sizeof(struct plat_serial8250_port);
96
int c = alchemy_get_uarts(ctype);
97
struct plat_serial8250_port *ports;
99
ports = kzalloc(s * (c + 1), GFP_KERNEL);
101
printk(KERN_INFO "Alchemy: no memory for UART data\n");
104
memcpy(ports, au1x00_uart_data[ctype], s * c);
105
au1xx0_uart_device.dev.platform_data = ports;
107
/* Fill up uartclk. */
108
for (s = 0; s < c; s++)
109
ports[s].uartclk = uartclk;
110
if (platform_device_register(&au1xx0_uart_device))
111
printk(KERN_INFO "Alchemy: failed to register UARTs\n");
100
114
/* OHCI (USB full speed host controller) */
101
115
static struct resource au1xxx_usb_ohci_resources[] = {
361
375
/* Macro to help defining the Ethernet MAC resources */
376
#define MAC_RES_COUNT 3 /* MAC regs base, MAC enable reg, MAC INT */
362
377
#define MAC_RES(_base, _enable, _irq) \
364
.start = CPHYSADDR(_base), \
365
.end = CPHYSADDR(_base + 0xffff), \
380
.end = _base + 0xffff, \
366
381
.flags = IORESOURCE_MEM, \
369
.start = CPHYSADDR(_enable), \
370
.end = CPHYSADDR(_enable + 0x3), \
385
.end = _enable + 0x3, \
371
386
.flags = IORESOURCE_MEM, \
376
391
.flags = IORESOURCE_IRQ \
379
static struct resource au1xxx_eth0_resources[] = {
380
#if defined(CONFIG_SOC_AU1000)
381
MAC_RES(AU1000_ETH0_BASE, AU1000_MAC0_ENABLE, AU1000_MAC0_DMA_INT),
382
#elif defined(CONFIG_SOC_AU1100)
383
MAC_RES(AU1100_ETH0_BASE, AU1100_MAC0_ENABLE, AU1100_MAC0_DMA_INT),
384
#elif defined(CONFIG_SOC_AU1550)
385
MAC_RES(AU1550_ETH0_BASE, AU1550_MAC0_ENABLE, AU1550_MAC0_DMA_INT),
386
#elif defined(CONFIG_SOC_AU1500)
387
MAC_RES(AU1500_ETH0_BASE, AU1500_MAC0_ENABLE, AU1500_MAC0_DMA_INT),
394
static struct resource au1xxx_eth0_resources[][MAC_RES_COUNT] __initdata = {
395
[ALCHEMY_CPU_AU1000] = {
396
MAC_RES(AU1000_MAC0_PHYS_ADDR,
397
AU1000_MACEN_PHYS_ADDR,
400
[ALCHEMY_CPU_AU1500] = {
401
MAC_RES(AU1500_MAC0_PHYS_ADDR,
402
AU1500_MACEN_PHYS_ADDR,
405
[ALCHEMY_CPU_AU1100] = {
406
MAC_RES(AU1000_MAC0_PHYS_ADDR,
407
AU1000_MACEN_PHYS_ADDR,
410
[ALCHEMY_CPU_AU1550] = {
411
MAC_RES(AU1000_MAC0_PHYS_ADDR,
412
AU1000_MACEN_PHYS_ADDR,
392
417
static struct au1000_eth_platform_data au1xxx_eth0_platform_data = {
393
418
.phy1_search_mac0 = 1,
396
421
static struct platform_device au1xxx_eth0_device = {
397
422
.name = "au1000-eth",
399
.num_resources = ARRAY_SIZE(au1xxx_eth0_resources),
400
.resource = au1xxx_eth0_resources,
424
.num_resources = MAC_RES_COUNT,
401
425
.dev.platform_data = &au1xxx_eth0_platform_data,
404
#ifndef CONFIG_SOC_AU1100
405
static struct resource au1xxx_eth1_resources[] = {
406
#if defined(CONFIG_SOC_AU1000)
407
MAC_RES(AU1000_ETH1_BASE, AU1000_MAC1_ENABLE, AU1000_MAC1_DMA_INT),
408
#elif defined(CONFIG_SOC_AU1550)
409
MAC_RES(AU1550_ETH1_BASE, AU1550_MAC1_ENABLE, AU1550_MAC1_DMA_INT),
410
#elif defined(CONFIG_SOC_AU1500)
411
MAC_RES(AU1500_ETH1_BASE, AU1500_MAC1_ENABLE, AU1500_MAC1_DMA_INT),
428
static struct resource au1xxx_eth1_resources[][MAC_RES_COUNT] __initdata = {
429
[ALCHEMY_CPU_AU1000] = {
430
MAC_RES(AU1000_MAC1_PHYS_ADDR,
431
AU1000_MACEN_PHYS_ADDR + 4,
434
[ALCHEMY_CPU_AU1500] = {
435
MAC_RES(AU1500_MAC1_PHYS_ADDR,
436
AU1500_MACEN_PHYS_ADDR + 4,
439
[ALCHEMY_CPU_AU1550] = {
440
MAC_RES(AU1000_MAC1_PHYS_ADDR,
441
AU1000_MACEN_PHYS_ADDR + 4,
415
446
static struct au1000_eth_platform_data au1xxx_eth1_platform_data = {
435
464
memcpy(&au1xxx_eth0_platform_data, eth_data,
436
465
sizeof(struct au1000_eth_platform_data));
437
#ifndef CONFIG_SOC_AU1100
439
467
memcpy(&au1xxx_eth1_platform_data, eth_data,
440
468
sizeof(struct au1000_eth_platform_data));
471
static void __init alchemy_setup_macs(int ctype)
474
unsigned char ethaddr[6];
475
struct resource *macres;
478
if (alchemy_get_macs(ctype) < 1)
481
macres = kmalloc(sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL);
483
printk(KERN_INFO "Alchemy: no memory for MAC0 resources\n");
486
memcpy(macres, au1xxx_eth0_resources[ctype],
487
sizeof(struct resource) * MAC_RES_COUNT);
488
au1xxx_eth0_device.resource = macres;
490
i = prom_get_ethernet_addr(ethaddr);
491
if (!i && !is_valid_ether_addr(au1xxx_eth0_platform_data.mac))
492
memcpy(au1xxx_eth0_platform_data.mac, ethaddr, 6);
494
ret = platform_device_register(&au1xxx_eth0_device);
496
printk(KERN_INFO "Alchemy: failed to register MAC0\n");
500
if (alchemy_get_macs(ctype) < 2)
503
macres = kmalloc(sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL);
505
printk(KERN_INFO "Alchemy: no memory for MAC1 resources\n");
508
memcpy(macres, au1xxx_eth1_resources[ctype],
509
sizeof(struct resource) * MAC_RES_COUNT);
510
au1xxx_eth1_device.resource = macres;
512
ethaddr[5] += 1; /* next addr for 2nd MAC */
513
if (!i && !is_valid_ether_addr(au1xxx_eth1_platform_data.mac))
514
memcpy(au1xxx_eth1_platform_data.mac, ethaddr, 6);
516
/* Register second MAC if enabled in pinfunc */
517
if (!(au_readl(SYS_PINFUNC) & (u32)SYS_PF_NI2)) {
518
ret = platform_device_register(&au1xxx_eth1_device);
520
printk(KERN_INFO "Alchemy: failed to register MAC1\n");
444
524
static struct platform_device *au1xxx_platform_devices[] __initdata = {
446
525
&au1xxx_usb_ohci_device,
447
526
#ifdef CONFIG_FB_AU1100
448
527
&au1100_lcd_device,
460
539
#ifdef SMBUS_PSC_BASE
461
540
&pbdb_smbus_device,
466
544
static int __init au1xxx_platform_init(void)
468
unsigned int uartclk = get_au1x00_uart_baud_base() * 16;
470
unsigned char ethaddr[6];
472
/* Fill up uartclk. */
473
for (i = 0; au1x00_uart_data[i].flags; i++)
474
au1x00_uart_data[i].uartclk = uartclk;
476
/* use firmware-provided mac addr if available and necessary */
477
i = prom_get_ethernet_addr(ethaddr);
478
if (!i && !is_valid_ether_addr(au1xxx_eth0_platform_data.mac))
479
memcpy(au1xxx_eth0_platform_data.mac, ethaddr, 6);
546
int err, ctype = alchemy_get_cputype();
548
alchemy_setup_uarts(ctype);
549
alchemy_setup_macs(ctype);
481
551
err = platform_add_devices(au1xxx_platform_devices,
482
552
ARRAY_SIZE(au1xxx_platform_devices));
483
#ifndef CONFIG_SOC_AU1100
484
ethaddr[5] += 1; /* next addr for 2nd MAC */
485
if (!i && !is_valid_ether_addr(au1xxx_eth1_platform_data.mac))
486
memcpy(au1xxx_eth1_platform_data.mac, ethaddr, 6);
488
/* Register second MAC if enabled in pinfunc */
489
if (!err && !(au_readl(SYS_PINFUNC) & (u32)SYS_PF_NI2))
490
err = platform_device_register(&au1xxx_eth1_device);