^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * QNAP TS-109/TS-209 Board Setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Maintainer: Byron Bradley <byron.bbradley@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/mtd/physmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/mtd/rawnand.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/mv643xx_eth.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/gpio_keys.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/serial_reg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/ata_platform.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <asm/mach/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include "common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include "mpp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include "orion5x.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include "tsx09-common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define QNAP_TS209_NOR_BOOT_BASE 0xf4000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define QNAP_TS209_NOR_BOOT_SIZE SZ_8M
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * 8MiB NOR flash. The struct mtd_partition is not in the same order as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * partitions on the device because we want to keep compatibility with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * existing QNAP firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * Layout as used by QNAP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * [2] 0x00000000-0x00200000 : "Kernel"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * [3] 0x00200000-0x00600000 : "RootFS1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * [4] 0x00600000-0x00700000 : "RootFS2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * [6] 0x00700000-0x00760000 : "NAS Config" (read-only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * [5] 0x00760000-0x00780000 : "U-Boot Config"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * [1] 0x00780000-0x00800000 : "U-Boot" (read-only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ***************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static struct mtd_partition qnap_ts209_partitions[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) .name = "U-Boot",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) .size = 0x00080000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) .offset = 0x00780000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) .mask_flags = MTD_WRITEABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) .name = "Kernel",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) .size = 0x00200000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) .offset = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) .name = "RootFS1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) .size = 0x00400000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) .offset = 0x00200000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) .name = "RootFS2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) .size = 0x00100000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) .offset = 0x00600000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) .name = "U-Boot Config",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) .size = 0x00020000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) .offset = 0x00760000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .name = "NAS Config",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) .size = 0x00060000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) .offset = 0x00700000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) .mask_flags = MTD_WRITEABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) static struct physmap_flash_data qnap_ts209_nor_flash_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) .width = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) .parts = qnap_ts209_partitions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) .nr_parts = ARRAY_SIZE(qnap_ts209_partitions)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static struct resource qnap_ts209_nor_flash_resource = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) .flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) .start = QNAP_TS209_NOR_BOOT_BASE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) .end = QNAP_TS209_NOR_BOOT_BASE + QNAP_TS209_NOR_BOOT_SIZE - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static struct platform_device qnap_ts209_nor_flash = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .name = "physmap-flash",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) .id = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) .platform_data = &qnap_ts209_nor_flash_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) .resource = &qnap_ts209_nor_flash_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) .num_resources = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * PCI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define QNAP_TS209_PCI_SLOT0_OFFS 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define QNAP_TS209_PCI_SLOT0_IRQ_PIN 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define QNAP_TS209_PCI_SLOT1_IRQ_PIN 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static void __init qnap_ts209_pci_preinit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * Configure PCI GPIO IRQ pins
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) pin = QNAP_TS209_PCI_SLOT0_IRQ_PIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if (gpio_request(pin, "PCI Int1") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) if (gpio_direction_input(pin) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) printk(KERN_ERR "qnap_ts209_pci_preinit failed to "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) "set_irq_type pin %d\n", pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) gpio_free(pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) printk(KERN_ERR "qnap_ts209_pci_preinit failed to gpio_request "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) "%d\n", pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) pin = QNAP_TS209_PCI_SLOT1_IRQ_PIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) if (gpio_request(pin, "PCI Int2") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (gpio_direction_input(pin) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) printk(KERN_ERR "qnap_ts209_pci_preinit failed "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) "to set_irq_type pin %d\n", pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) gpio_free(pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) printk(KERN_ERR "qnap_ts209_pci_preinit failed to gpio_request "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) "%d\n", pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static int __init qnap_ts209_pci_map_irq(const struct pci_dev *dev, u8 slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) u8 pin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * Check for devices with hard-wired IRQs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) irq = orion5x_pci_map_irq(dev, slot, pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (irq != -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) return irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * PCI IRQs are connected via GPIOs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) switch (slot - QNAP_TS209_PCI_SLOT0_OFFS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) return gpio_to_irq(QNAP_TS209_PCI_SLOT0_IRQ_PIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) return gpio_to_irq(QNAP_TS209_PCI_SLOT1_IRQ_PIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static struct hw_pci qnap_ts209_pci __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) .nr_controllers = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) .preinit = qnap_ts209_pci_preinit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) .setup = orion5x_pci_sys_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) .scan = orion5x_pci_sys_scan_bus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) .map_irq = qnap_ts209_pci_map_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) static int __init qnap_ts209_pci_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (machine_is_ts209())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) pci_common_init(&qnap_ts209_pci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) subsys_initcall(qnap_ts209_pci_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * RTC S35390A on I2C bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) #define TS209_RTC_GPIO 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static struct i2c_board_info __initdata qnap_ts209_i2c_rtc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) I2C_BOARD_INFO("s35390a", 0x30),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) .irq = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) /****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * GPIO Attached Keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * Power button is attached to the PIC microcontroller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #define QNAP_TS209_GPIO_KEY_MEDIA 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #define QNAP_TS209_GPIO_KEY_RESET 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) static struct gpio_keys_button qnap_ts209_buttons[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) .code = KEY_COPY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) .gpio = QNAP_TS209_GPIO_KEY_MEDIA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) .desc = "USB Copy Button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) .code = KEY_RESTART,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) .gpio = QNAP_TS209_GPIO_KEY_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) .desc = "Reset Button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) static struct gpio_keys_platform_data qnap_ts209_button_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) .buttons = qnap_ts209_buttons,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) .nbuttons = ARRAY_SIZE(qnap_ts209_buttons),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static struct platform_device qnap_ts209_button_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) .name = "gpio-keys",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) .id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) .num_resources = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) .platform_data = &qnap_ts209_button_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * SATA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static struct mv_sata_platform_data qnap_ts209_sata_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) .n_ports = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) * General Setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) static unsigned int ts209_mpp_modes[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) MPP0_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) MPP1_GPIO, /* USB copy button */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) MPP2_GPIO, /* Load defaults button */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) MPP3_GPIO, /* GPIO RTC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) MPP4_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) MPP5_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) MPP6_GPIO, /* PCI Int A */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) MPP7_GPIO, /* PCI Int B */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) MPP8_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) MPP9_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) MPP10_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) MPP11_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) MPP12_SATA_LED, /* SATA 0 presence */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) MPP13_SATA_LED, /* SATA 1 presence */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) MPP14_SATA_LED, /* SATA 0 active */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) MPP15_SATA_LED, /* SATA 1 active */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) MPP16_UART, /* UART1 RXD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) MPP17_UART, /* UART1 TXD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) MPP18_GPIO, /* SW_RST */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) MPP19_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) static void __init qnap_ts209_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) * Setup basic Orion functions. Need to be called early.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) orion5x_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) orion5x_mpp_conf(ts209_mpp_modes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * MPP[20] PCI clock 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * MPP[21] PCI clock 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) * MPP[22] USB 0 over current
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * MPP[23-25] Reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) * Configure peripherals.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) ORION_MBUS_DEVBUS_BOOT_ATTR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) QNAP_TS209_NOR_BOOT_BASE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) QNAP_TS209_NOR_BOOT_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) platform_device_register(&qnap_ts209_nor_flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) orion5x_ehci0_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) orion5x_ehci1_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) qnap_tsx09_find_mac_addr(QNAP_TS209_NOR_BOOT_BASE +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) qnap_ts209_partitions[5].offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) qnap_ts209_partitions[5].size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) orion5x_eth_init(&qnap_tsx09_eth_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) orion5x_i2c_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) orion5x_sata_init(&qnap_ts209_sata_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) orion5x_uart0_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) orion5x_uart1_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) orion5x_xor_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) platform_device_register(&qnap_ts209_button_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) /* Get RTC IRQ and register the chip */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) if (gpio_request(TS209_RTC_GPIO, "rtc") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) if (gpio_direction_input(TS209_RTC_GPIO) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) qnap_ts209_i2c_rtc.irq = gpio_to_irq(TS209_RTC_GPIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) gpio_free(TS209_RTC_GPIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) if (qnap_ts209_i2c_rtc.irq == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) pr_warn("qnap_ts209_init: failed to get RTC IRQ\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) i2c_register_board_info(0, &qnap_ts209_i2c_rtc, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) /* register tsx09 specific power-off method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) pm_power_off = qnap_tsx09_power_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) MACHINE_START(TS209, "QNAP TS-109/TS-209")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) /* Maintainer: Byron Bradley <byron.bbradley@gmail.com> */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) .atag_offset = 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) .nr_irqs = ORION5X_NR_IRQS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) .init_machine = qnap_ts209_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) .map_io = orion5x_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) .init_early = orion5x_init_early,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) .init_irq = orion5x_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) .init_time = orion5x_timer_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) .fixup = tag_fixup_mem32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) .restart = orion5x_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) MACHINE_END