^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-409 Board Setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Maintainer: Sylver Bruneau <sylver.bruneau@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2008 Sylver Bruneau <sylver.bruneau@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright (C) 2008 Martin Michlmayr <tbm@cyrius.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/mtd/physmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/mv643xx_eth.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/gpio_keys.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/serial_reg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <asm/mach/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include "common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include "mpp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include "orion5x.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include "tsx09-common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * QNAP TS-409 Info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * QNAP TS-409 hardware :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * - Marvell 88F5281-D0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * - Marvell 88SX7042 SATA controller (PCIe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * - Marvell 88E1118 Gigabit Ethernet PHY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * - RTC S35390A (@0x30) on I2C bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * - 8MB NOR flash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * - 256MB of DDR-2 RAM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * 8MB NOR flash Device bus boot chip select
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define QNAP_TS409_NOR_BOOT_BASE 0xff800000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define QNAP_TS409_NOR_BOOT_SIZE SZ_8M
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * 8MiB NOR flash. The struct mtd_partition is not in the same order as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * partitions on the device because we want to keep compatibility with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * existing QNAP firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * Layout as used by QNAP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * [2] 0x00000000-0x00200000 : "Kernel"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * [3] 0x00200000-0x00600000 : "RootFS1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * [4] 0x00600000-0x00700000 : "RootFS2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * [6] 0x00700000-0x00760000 : "NAS Config" (read-only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * [5] 0x00760000-0x00780000 : "U-Boot Config"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * [1] 0x00780000-0x00800000 : "U-Boot" (read-only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ***************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static struct mtd_partition qnap_ts409_partitions[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) .name = "U-Boot",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .size = 0x00080000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) .offset = 0x00780000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) .mask_flags = MTD_WRITEABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) .name = "Kernel",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) .size = 0x00200000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) .offset = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) .name = "RootFS1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) .size = 0x00400000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) .offset = 0x00200000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) .name = "RootFS2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) .size = 0x00100000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) .offset = 0x00600000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) .name = "U-Boot Config",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) .size = 0x00020000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) .offset = 0x00760000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .name = "NAS Config",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) .size = 0x00060000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) .offset = 0x00700000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) .mask_flags = MTD_WRITEABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static struct physmap_flash_data qnap_ts409_nor_flash_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) .width = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) .parts = qnap_ts409_partitions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) .nr_parts = ARRAY_SIZE(qnap_ts409_partitions)
^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) static struct resource qnap_ts409_nor_flash_resource = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) .flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) .start = QNAP_TS409_NOR_BOOT_BASE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) .end = QNAP_TS409_NOR_BOOT_BASE + QNAP_TS409_NOR_BOOT_SIZE - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static struct platform_device qnap_ts409_nor_flash = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) .name = "physmap-flash",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) .id = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) .dev = { .platform_data = &qnap_ts409_nor_flash_data, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) .num_resources = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) .resource = &qnap_ts409_nor_flash_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * PCI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static int __init qnap_ts409_pci_map_irq(const struct pci_dev *dev, u8 slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) u8 pin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * Check for devices with hard-wired IRQs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) irq = orion5x_pci_map_irq(dev, slot, pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (irq != -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) return irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * PCI isn't used on the TS-409
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static struct hw_pci qnap_ts409_pci __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) .nr_controllers = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) .setup = orion5x_pci_sys_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) .scan = orion5x_pci_sys_scan_bus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) .map_irq = qnap_ts409_pci_map_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static int __init qnap_ts409_pci_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (machine_is_ts409())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) pci_common_init(&qnap_ts409_pci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) subsys_initcall(qnap_ts409_pci_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * RTC S35390A on I2C bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #define TS409_RTC_GPIO 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) static struct i2c_board_info __initdata qnap_ts409_i2c_rtc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) I2C_BOARD_INFO("s35390a", 0x30),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) };
^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) * LEDs attached to GPIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static struct gpio_led ts409_led_pins[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) .name = "ts409:red:sata1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) .gpio = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) .name = "ts409:red:sata2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) .gpio = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) .name = "ts409:red:sata3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) .gpio = 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) .name = "ts409:red:sata4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) .gpio = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) },
^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) static struct gpio_led_platform_data ts409_led_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) .leds = ts409_led_pins,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) .num_leds = ARRAY_SIZE(ts409_led_pins),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static struct platform_device ts409_leds = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) .name = "leds-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) .id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) .platform_data = &ts409_led_data,
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) /****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * GPIO Attached Keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * Power button is attached to the PIC microcontroller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) #define QNAP_TS409_GPIO_KEY_RESET 14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) #define QNAP_TS409_GPIO_KEY_MEDIA 15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static struct gpio_keys_button qnap_ts409_buttons[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) .code = KEY_RESTART,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) .gpio = QNAP_TS409_GPIO_KEY_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) .desc = "Reset Button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) .code = KEY_COPY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) .gpio = QNAP_TS409_GPIO_KEY_MEDIA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) .desc = "USB Copy Button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) .active_low = 1,
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) static struct gpio_keys_platform_data qnap_ts409_button_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) .buttons = qnap_ts409_buttons,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) .nbuttons = ARRAY_SIZE(qnap_ts409_buttons),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static struct platform_device qnap_ts409_button_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) .name = "gpio-keys",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) .id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) .num_resources = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) .platform_data = &qnap_ts409_button_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) };
^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) * General Setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) static unsigned int ts409_mpp_modes[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) MPP0_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) MPP1_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) MPP2_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) MPP3_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) MPP4_GPIO, /* HDD 1 status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) MPP5_GPIO, /* HDD 2 status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) MPP6_GPIO, /* HDD 3 status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) MPP7_GPIO, /* HDD 4 status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) MPP8_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) MPP9_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) MPP10_GPIO, /* RTC int */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) MPP11_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) MPP12_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) MPP13_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) MPP14_GPIO, /* SW_RST */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) MPP15_GPIO, /* USB copy button */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) MPP16_UART, /* UART1 RXD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) MPP17_UART, /* UART1 TXD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) MPP18_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) MPP19_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) static void __init qnap_ts409_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * Setup basic Orion functions. Need to be called early.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) orion5x_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) orion5x_mpp_conf(ts409_mpp_modes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * Configure peripherals.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) ORION_MBUS_DEVBUS_BOOT_ATTR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) QNAP_TS409_NOR_BOOT_BASE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) QNAP_TS409_NOR_BOOT_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) platform_device_register(&qnap_ts409_nor_flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) orion5x_ehci0_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) qnap_tsx09_find_mac_addr(QNAP_TS409_NOR_BOOT_BASE +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) qnap_ts409_partitions[5].offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) qnap_ts409_partitions[5].size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) orion5x_eth_init(&qnap_tsx09_eth_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) orion5x_i2c_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) orion5x_uart0_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) orion5x_uart1_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) platform_device_register(&qnap_ts409_button_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) /* Get RTC IRQ and register the chip */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) if (gpio_request(TS409_RTC_GPIO, "rtc") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) if (gpio_direction_input(TS409_RTC_GPIO) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) qnap_ts409_i2c_rtc.irq = gpio_to_irq(TS409_RTC_GPIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) gpio_free(TS409_RTC_GPIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) if (qnap_ts409_i2c_rtc.irq == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) pr_warn("qnap_ts409_init: failed to get RTC IRQ\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) i2c_register_board_info(0, &qnap_ts409_i2c_rtc, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) platform_device_register(&ts409_leds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) /* register tsx09 specific power-off method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) pm_power_off = qnap_tsx09_power_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) MACHINE_START(TS409, "QNAP TS-409")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) /* Maintainer: Sylver Bruneau <sylver.bruneau@gmail.com> */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) .atag_offset = 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) .nr_irqs = ORION5X_NR_IRQS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) .init_machine = qnap_ts409_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) .map_io = orion5x_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) .init_early = orion5x_init_early,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) .init_irq = orion5x_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) .init_time = orion5x_timer_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) .fixup = tag_fixup_mem32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) .restart = orion5x_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) MACHINE_END