arm64: dts: Revert "specify console via command line"
[linux/fpc-iii.git] / arch / arm / mach-iop32x / n2100.c
blob5382a93ad0f8ce9e8f18ceb7b0497f5d10b59a0c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * arch/arm/mach-iop32x/n2100.c
5 * Board support code for the Thecus N2100 platform.
7 * Author: Rory Bolt <rorybolt@pacbell.net>
8 * Copyright (C) 2002 Rory Bolt
9 * Copyright 2003 (c) MontaVista, Software, Inc.
10 * Copyright (C) 2004 Intel Corp.
13 #include <linux/mm.h>
14 #include <linux/init.h>
15 #include <linux/f75375s.h>
16 #include <linux/leds-pca9532.h>
17 #include <linux/delay.h>
18 #include <linux/kernel.h>
19 #include <linux/pci.h>
20 #include <linux/pm.h>
21 #include <linux/string.h>
22 #include <linux/serial_core.h>
23 #include <linux/serial_8250.h>
24 #include <linux/mtd/physmap.h>
25 #include <linux/i2c.h>
26 #include <linux/platform_device.h>
27 #include <linux/reboot.h>
28 #include <linux/io.h>
29 #include <linux/gpio.h>
30 #include <linux/gpio/machine.h>
31 #include <asm/irq.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34 #include <asm/mach/pci.h>
35 #include <asm/mach/time.h>
36 #include <asm/mach-types.h>
37 #include <asm/page.h>
38 #include <asm/pgtable.h>
40 #include "hardware.h"
41 #include "irqs.h"
42 #include "gpio-iop32x.h"
45 * N2100 timer tick configuration.
47 static void __init n2100_timer_init(void)
49 /* 33.000 MHz crystal. */
50 iop_init_time(198000000);
55 * N2100 I/O.
57 static struct map_desc n2100_io_desc[] __initdata = {
58 { /* on-board devices */
59 .virtual = N2100_UART,
60 .pfn = __phys_to_pfn(N2100_UART),
61 .length = 0x00100000,
62 .type = MT_DEVICE
66 void __init n2100_map_io(void)
68 iop3xx_map_io();
69 iotable_init(n2100_io_desc, ARRAY_SIZE(n2100_io_desc));
74 * N2100 PCI.
76 static int n2100_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
78 int irq;
80 if (PCI_SLOT(dev->devfn) == 1) {
81 /* RTL8110SB #1 */
82 irq = IRQ_IOP32X_XINT0;
83 } else if (PCI_SLOT(dev->devfn) == 2) {
84 /* RTL8110SB #2 */
85 irq = IRQ_IOP32X_XINT3;
86 } else if (PCI_SLOT(dev->devfn) == 3) {
87 /* Sil3512 */
88 irq = IRQ_IOP32X_XINT2;
89 } else if (PCI_SLOT(dev->devfn) == 4 && pin == 1) {
90 /* VT6212 INTA */
91 irq = IRQ_IOP32X_XINT1;
92 } else if (PCI_SLOT(dev->devfn) == 4 && pin == 2) {
93 /* VT6212 INTB */
94 irq = IRQ_IOP32X_XINT0;
95 } else if (PCI_SLOT(dev->devfn) == 4 && pin == 3) {
96 /* VT6212 INTC */
97 irq = IRQ_IOP32X_XINT2;
98 } else if (PCI_SLOT(dev->devfn) == 5) {
99 /* Mini-PCI slot */
100 irq = IRQ_IOP32X_XINT3;
101 } else {
102 printk(KERN_ERR "n2100_pci_map_irq() called for unknown "
103 "device PCI:%d:%d:%d\n", dev->bus->number,
104 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
105 irq = -1;
108 return irq;
111 static struct hw_pci n2100_pci __initdata = {
112 .nr_controllers = 1,
113 .ops = &iop3xx_ops,
114 .setup = iop3xx_pci_setup,
115 .preinit = iop3xx_pci_preinit,
116 .map_irq = n2100_pci_map_irq,
120 * Both r8169 chips on the n2100 exhibit PCI parity problems. Set
121 * the ->broken_parity_status flag for both ports so that the r8169
122 * driver knows it should ignore error interrupts.
124 static void n2100_fixup_r8169(struct pci_dev *dev)
126 if (dev->bus->number == 0 &&
127 (dev->devfn == PCI_DEVFN(1, 0) ||
128 dev->devfn == PCI_DEVFN(2, 0)))
129 dev->broken_parity_status = 1;
131 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK, PCI_ANY_ID, n2100_fixup_r8169);
133 static int __init n2100_pci_init(void)
135 if (machine_is_n2100())
136 pci_common_init(&n2100_pci);
138 return 0;
141 subsys_initcall(n2100_pci_init);
145 * N2100 machine initialisation.
147 static struct physmap_flash_data n2100_flash_data = {
148 .width = 2,
151 static struct resource n2100_flash_resource = {
152 .start = 0xf0000000,
153 .end = 0xf0ffffff,
154 .flags = IORESOURCE_MEM,
157 static struct platform_device n2100_flash_device = {
158 .name = "physmap-flash",
159 .id = 0,
160 .dev = {
161 .platform_data = &n2100_flash_data,
163 .num_resources = 1,
164 .resource = &n2100_flash_resource,
168 static struct plat_serial8250_port n2100_serial_port[] = {
170 .mapbase = N2100_UART,
171 .membase = (char *)N2100_UART,
172 .irq = 0,
173 .flags = UPF_SKIP_TEST | UPF_AUTO_IRQ | UPF_SHARE_IRQ,
174 .iotype = UPIO_MEM,
175 .regshift = 0,
176 .uartclk = 1843200,
178 { },
181 static struct resource n2100_uart_resource = {
182 .start = N2100_UART,
183 .end = N2100_UART + 7,
184 .flags = IORESOURCE_MEM,
187 static struct platform_device n2100_serial_device = {
188 .name = "serial8250",
189 .id = PLAT8250_DEV_PLATFORM,
190 .dev = {
191 .platform_data = n2100_serial_port,
193 .num_resources = 1,
194 .resource = &n2100_uart_resource,
197 static struct f75375s_platform_data n2100_f75375s = {
198 .pwm = { 255, 255 },
199 .pwm_enable = { 0, 0 },
202 static struct pca9532_platform_data n2100_leds = {
203 .leds = {
204 { .name = "n2100:red:satafail0",
205 .state = PCA9532_OFF,
206 .type = PCA9532_TYPE_LED,
208 { .name = "n2100:red:satafail1",
209 .state = PCA9532_OFF,
210 .type = PCA9532_TYPE_LED,
212 { .name = "n2100:blue:usb",
213 .state = PCA9532_OFF,
214 .type = PCA9532_TYPE_LED,
216 { .type = PCA9532_TYPE_NONE },
218 { .type = PCA9532_TYPE_NONE },
219 { .type = PCA9532_TYPE_NONE },
220 { .type = PCA9532_TYPE_NONE },
221 { .name = "n2100:red:usb",
222 .state = PCA9532_OFF,
223 .type = PCA9532_TYPE_LED,
226 { .type = PCA9532_TYPE_NONE }, /* power OFF gpio */
227 { .type = PCA9532_TYPE_NONE }, /* reset gpio */
228 { .type = PCA9532_TYPE_NONE },
229 { .type = PCA9532_TYPE_NONE },
231 { .type = PCA9532_TYPE_NONE },
232 { .name = "n2100:orange:system",
233 .state = PCA9532_OFF,
234 .type = PCA9532_TYPE_LED,
236 { .name = "n2100:red:system",
237 .state = PCA9532_OFF,
238 .type = PCA9532_TYPE_LED,
240 { .name = "N2100 beeper" ,
241 .state = PCA9532_OFF,
242 .type = PCA9532_TYPE_N2100_BEEP,
245 .psc = { 0, 0 },
246 .pwm = { 0, 0 },
249 static struct i2c_board_info __initdata n2100_i2c_devices[] = {
251 I2C_BOARD_INFO("rs5c372b", 0x32),
254 I2C_BOARD_INFO("f75375", 0x2e),
255 .platform_data = &n2100_f75375s,
258 I2C_BOARD_INFO("pca9532", 0x60),
259 .platform_data = &n2100_leds,
264 * Pull PCA9532 GPIO #8 low to power off the machine.
266 static void n2100_power_off(void)
268 local_irq_disable();
270 /* Start condition, I2C address of PCA9532, write transaction. */
271 *IOP3XX_IDBR0 = 0xc0;
272 *IOP3XX_ICR0 = 0xe9;
273 mdelay(1);
275 /* Write address 0x08. */
276 *IOP3XX_IDBR0 = 0x08;
277 *IOP3XX_ICR0 = 0xe8;
278 mdelay(1);
280 /* Write data 0x01, stop condition. */
281 *IOP3XX_IDBR0 = 0x01;
282 *IOP3XX_ICR0 = 0xea;
284 while (1)
288 static void n2100_restart(enum reboot_mode mode, const char *cmd)
290 int ret;
292 ret = gpio_direction_output(N2100_HARDWARE_RESET, 0);
293 if (ret) {
294 pr_crit("could not drive reset GPIO low\n");
295 return;
297 /* Wait for reset to happen */
298 while (1)
303 static struct timer_list power_button_poll_timer;
305 static void power_button_poll(struct timer_list *unused)
307 if (gpio_get_value(N2100_POWER_BUTTON) == 0) {
308 ctrl_alt_del();
309 return;
312 power_button_poll_timer.expires = jiffies + (HZ / 10);
313 add_timer(&power_button_poll_timer);
316 static int __init n2100_request_gpios(void)
318 int ret;
320 if (!machine_is_n2100())
321 return 0;
323 ret = gpio_request(N2100_HARDWARE_RESET, "reset");
324 if (ret)
325 pr_err("could not request reset GPIO\n");
327 ret = gpio_request(N2100_POWER_BUTTON, "power");
328 if (ret)
329 pr_err("could not request power GPIO\n");
330 else {
331 ret = gpio_direction_input(N2100_POWER_BUTTON);
332 if (ret)
333 pr_err("could not set power GPIO as input\n");
335 /* Set up power button poll timer */
336 timer_setup(&power_button_poll_timer, power_button_poll, 0);
337 power_button_poll_timer.expires = jiffies + (HZ / 10);
338 add_timer(&power_button_poll_timer);
339 return 0;
341 device_initcall(n2100_request_gpios);
343 static void __init n2100_init_machine(void)
345 register_iop32x_gpio();
346 gpiod_add_lookup_table(&iop3xx_i2c0_gpio_lookup);
347 platform_device_register(&iop3xx_i2c0_device);
348 platform_device_register(&n2100_flash_device);
349 platform_device_register(&n2100_serial_device);
350 platform_device_register(&iop3xx_dma_0_channel);
351 platform_device_register(&iop3xx_dma_1_channel);
353 i2c_register_board_info(0, n2100_i2c_devices,
354 ARRAY_SIZE(n2100_i2c_devices));
356 pm_power_off = n2100_power_off;
359 MACHINE_START(N2100, "Thecus N2100")
360 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
361 .atag_offset = 0x100,
362 .map_io = n2100_map_io,
363 .init_irq = iop32x_init_irq,
364 .init_time = n2100_timer_init,
365 .init_machine = n2100_init_machine,
366 .restart = n2100_restart,
367 MACHINE_END