Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 1 | /* |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame^] | 2 | * Pb1550 board support. |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 3 | * |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame^] | 4 | * Copyright (C) 2009-2011 Manuel Lauss |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
Manuel Lauss | 3766386 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 21 | #include <linux/dma-mapping.h> |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 22 | #include <linux/init.h> |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame^] | 23 | #include <linux/interrupt.h> |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 24 | #include <linux/platform_device.h> |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 25 | #include <asm/mach-au1x00/au1000.h> |
Manuel Lauss | 3766386 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 26 | #include <asm/mach-au1x00/au1xxx_dbdma.h> |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame^] | 27 | #include <asm/mach-au1x00/gpio.h> |
Manuel Lauss | 206aa6c | 2009-10-19 12:53:37 +0200 | [diff] [blame] | 28 | #include <asm/mach-db1x00/bcsr.h> |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame^] | 29 | #include "platform.h" |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 30 | |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame^] | 31 | const char *get_system_type(void) |
| 32 | { |
| 33 | return "PB1550"; |
| 34 | } |
| 35 | |
| 36 | void __init board_setup(void) |
| 37 | { |
| 38 | u32 pin_func; |
| 39 | |
| 40 | bcsr_init(PB1550_BCSR_PHYS_ADDR, |
| 41 | PB1550_BCSR_PHYS_ADDR + PB1550_BCSR_HEXLED_OFS); |
| 42 | |
| 43 | alchemy_gpio2_enable(); |
| 44 | |
| 45 | /* |
| 46 | * Enable PSC1 SYNC for AC'97. Normaly done in audio driver, |
| 47 | * but it is board specific code, so put it here. |
| 48 | */ |
| 49 | pin_func = au_readl(SYS_PINFUNC); |
| 50 | au_sync(); |
| 51 | pin_func |= SYS_PF_MUST_BE_SET | SYS_PF_PSC1_S1; |
| 52 | au_writel(pin_func, SYS_PINFUNC); |
| 53 | |
| 54 | bcsr_write(BCSR_PCMCIA, 0); /* turn off PCMCIA power */ |
| 55 | |
| 56 | printk(KERN_INFO "AMD Alchemy Pb1550 Board\n"); |
| 57 | } |
| 58 | |
| 59 | /******************************************************************************/ |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 60 | |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 61 | static int pb1550_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin) |
| 62 | { |
| 63 | if ((slot < 12) || (slot > 13) || pin == 0) |
| 64 | return -1; |
| 65 | if (slot == 12) { |
| 66 | switch (pin) { |
| 67 | case 1: return AU1500_PCI_INTB; |
| 68 | case 2: return AU1500_PCI_INTC; |
| 69 | case 3: return AU1500_PCI_INTD; |
| 70 | case 4: return AU1500_PCI_INTA; |
| 71 | } |
| 72 | } |
| 73 | if (slot == 13) { |
| 74 | switch (pin) { |
| 75 | case 1: return AU1500_PCI_INTA; |
| 76 | case 2: return AU1500_PCI_INTB; |
| 77 | case 3: return AU1500_PCI_INTC; |
| 78 | case 4: return AU1500_PCI_INTD; |
| 79 | } |
| 80 | } |
| 81 | return -1; |
| 82 | } |
| 83 | |
| 84 | static struct resource alchemy_pci_host_res[] = { |
| 85 | [0] = { |
| 86 | .start = AU1500_PCI_PHYS_ADDR, |
| 87 | .end = AU1500_PCI_PHYS_ADDR + 0xfff, |
| 88 | .flags = IORESOURCE_MEM, |
| 89 | }, |
| 90 | }; |
| 91 | |
| 92 | static struct alchemy_pci_platdata pb1550_pci_pd = { |
| 93 | .board_map_irq = pb1550_map_pci_irq, |
| 94 | }; |
| 95 | |
| 96 | static struct platform_device pb1550_pci_host = { |
| 97 | .dev.platform_data = &pb1550_pci_pd, |
| 98 | .name = "alchemy-pci", |
| 99 | .id = 0, |
| 100 | .num_resources = ARRAY_SIZE(alchemy_pci_host_res), |
| 101 | .resource = alchemy_pci_host_res, |
| 102 | }; |
| 103 | |
Manuel Lauss | 3766386 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 104 | static struct resource au1550_psc2_res[] = { |
| 105 | [0] = { |
| 106 | .start = AU1550_PSC2_PHYS_ADDR, |
| 107 | .end = AU1550_PSC2_PHYS_ADDR + 0xfff, |
| 108 | .flags = IORESOURCE_MEM, |
| 109 | }, |
| 110 | [1] = { |
| 111 | .start = AU1550_PSC2_INT, |
| 112 | .end = AU1550_PSC2_INT, |
| 113 | .flags = IORESOURCE_IRQ, |
| 114 | }, |
| 115 | [2] = { |
| 116 | .start = AU1550_DSCR_CMD0_PSC2_TX, |
| 117 | .end = AU1550_DSCR_CMD0_PSC2_TX, |
| 118 | .flags = IORESOURCE_DMA, |
| 119 | }, |
| 120 | [3] = { |
| 121 | .start = AU1550_DSCR_CMD0_PSC2_RX, |
| 122 | .end = AU1550_DSCR_CMD0_PSC2_RX, |
| 123 | .flags = IORESOURCE_DMA, |
| 124 | }, |
| 125 | }; |
| 126 | |
| 127 | static struct platform_device pb1550_i2c_dev = { |
| 128 | .name = "au1xpsc_smbus", |
| 129 | .id = 0, /* bus number */ |
| 130 | .num_resources = ARRAY_SIZE(au1550_psc2_res), |
| 131 | .resource = au1550_psc2_res, |
| 132 | }; |
| 133 | |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 134 | static int __init pb1550_dev_init(void) |
| 135 | { |
Manuel Lauss | 206aa6c | 2009-10-19 12:53:37 +0200 | [diff] [blame] | 136 | int swapped; |
| 137 | |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame^] | 138 | irq_set_irq_type(AU1550_GPIO0_INT, IRQF_TRIGGER_LOW); |
| 139 | irq_set_irq_type(AU1550_GPIO1_INT, IRQF_TRIGGER_LOW); |
| 140 | irq_set_irq_type(AU1550_GPIO201_205_INT, IRQF_TRIGGER_HIGH); |
| 141 | |
| 142 | /* enable both PCMCIA card irqs in the shared line */ |
| 143 | alchemy_gpio2_enable_int(201); |
| 144 | alchemy_gpio2_enable_int(202); |
| 145 | |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 146 | /* Pb1550, like all others, also has statuschange irqs; however they're |
| 147 | * wired up on one of the Au1550's shared GPIO201_205 line, which also |
| 148 | * services the PCMCIA card interrupts. So we ignore statuschange and |
| 149 | * use the GPIO201_205 exclusively for card interrupts, since a) pcmcia |
| 150 | * drivers are used to shared irqs and b) statuschange isn't really use- |
| 151 | * ful anyway. |
| 152 | */ |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 153 | db1x_register_pcmcia_socket( |
| 154 | AU1000_PCMCIA_ATTR_PHYS_ADDR, |
| 155 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1, |
| 156 | AU1000_PCMCIA_MEM_PHYS_ADDR, |
| 157 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1, |
| 158 | AU1000_PCMCIA_IO_PHYS_ADDR, |
| 159 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1, |
| 160 | AU1550_GPIO201_205_INT, AU1550_GPIO0_INT, 0, 0, 0); |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 161 | |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 162 | db1x_register_pcmcia_socket( |
| 163 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x008000000, |
| 164 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x008400000 - 1, |
| 165 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x008000000, |
| 166 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x008400000 - 1, |
| 167 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x008000000, |
| 168 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x008010000 - 1, |
| 169 | AU1550_GPIO201_205_INT, AU1550_GPIO1_INT, 0, 0, 1); |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 170 | |
Manuel Lauss | 206aa6c | 2009-10-19 12:53:37 +0200 | [diff] [blame] | 171 | swapped = bcsr_read(BCSR_STATUS) & BCSR_STATUS_PB1550_SWAPBOOT; |
| 172 | db1x_register_norflash(128 * 1024 * 1024, 4, swapped); |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 173 | platform_device_register(&pb1550_pci_host); |
Manuel Lauss | 3766386 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 174 | platform_device_register(&pb1550_i2c_dev); |
Manuel Lauss | 206aa6c | 2009-10-19 12:53:37 +0200 | [diff] [blame] | 175 | |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 176 | return 0; |
| 177 | } |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 178 | arch_initcall(pb1550_dev_init); |