^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * arch/arm/mach-orion5x/net2big-setup.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * LaCie 2Big Network NAS setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * This file is licensed under the terms of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * License version 2. This program is licensed "as is" without any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * warranty of any kind, whether express or implied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/platform_device.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/ata_platform.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <plat/orion-gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include "common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include "mpp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include "orion5x.h"
^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) * LaCie 2Big Network Info
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * 512KB NOR flash Device bus boot chip select
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define NET2BIG_NOR_BOOT_BASE 0xfff80000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define NET2BIG_NOR_BOOT_SIZE SZ_512K
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * 512KB NOR Flash on Boot Device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * TODO: Check write support on flash MX29LV400CBTC-70G
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static struct mtd_partition net2big_partitions[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) .name = "Full512kb",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) .size = MTDPART_SIZ_FULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) .offset = 0x00000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) .mask_flags = MTD_WRITEABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static struct physmap_flash_data net2big_nor_flash_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) .width = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) .parts = net2big_partitions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) .nr_parts = ARRAY_SIZE(net2big_partitions),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static struct resource net2big_nor_flash_resource = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) .flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .start = NET2BIG_NOR_BOOT_BASE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) .end = NET2BIG_NOR_BOOT_BASE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) + NET2BIG_NOR_BOOT_SIZE - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static struct platform_device net2big_nor_flash = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) .name = "physmap-flash",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) .id = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) .platform_data = &net2big_nor_flash_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) .num_resources = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) .resource = &net2big_nor_flash_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * Ethernet
^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 mv643xx_eth_platform_data net2big_eth_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .phy_addr = MV643XX_ETH_PHY_ADDR(8),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * I2C devices
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * i2c addr | chip | description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * 0x32 | Ricoh 5C372b | RTC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * 0x50 | HT24LC08 | eeprom (1kB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static struct i2c_board_info __initdata net2big_i2c_devices[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) I2C_BOARD_INFO("rs5c372b", 0x32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) I2C_BOARD_INFO("24c08", 0x50),
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * SATA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static struct mv_sata_platform_data net2big_sata_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) .n_ports = 2,
^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) #define NET2BIG_GPIO_SATA_POWER_REQ 19
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define NET2BIG_GPIO_SATA0_POWER 23
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #define NET2BIG_GPIO_SATA1_POWER 25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static void __init net2big_sata_power_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) /* Configure GPIOs over MPP max number. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) orion_gpio_set_valid(NET2BIG_GPIO_SATA0_POWER, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) orion_gpio_set_valid(NET2BIG_GPIO_SATA1_POWER, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) err = gpio_request(NET2BIG_GPIO_SATA0_POWER, "SATA0 power status");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if (err == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) err = gpio_direction_input(NET2BIG_GPIO_SATA0_POWER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) gpio_free(NET2BIG_GPIO_SATA0_POWER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) pr_err("net2big: failed to setup SATA0 power GPIO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) err = gpio_request(NET2BIG_GPIO_SATA1_POWER, "SATA1 power status");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (err == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) err = gpio_direction_input(NET2BIG_GPIO_SATA1_POWER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) gpio_free(NET2BIG_GPIO_SATA1_POWER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) pr_err("net2big: failed to setup SATA1 power GPIO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) goto err_free_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) err = gpio_request(NET2BIG_GPIO_SATA_POWER_REQ, "SATA power request");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if (err == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) err = gpio_direction_output(NET2BIG_GPIO_SATA_POWER_REQ, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) gpio_free(NET2BIG_GPIO_SATA_POWER_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) pr_err("net2big: failed to setup SATA power request GPIO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) goto err_free_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) if (gpio_get_value(NET2BIG_GPIO_SATA0_POWER) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) gpio_get_value(NET2BIG_GPIO_SATA1_POWER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) return;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * SATA power up on both disk is done by pulling high the CPLD power
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * request line. The 300ms delay is related to the CPLD clock and is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * needed to be sure that the CPLD has take into account the low line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) msleep(300);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) gpio_set_value(NET2BIG_GPIO_SATA_POWER_REQ, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) pr_info("net2big: power up SATA hard disks\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) err_free_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) gpio_free(NET2BIG_GPIO_SATA1_POWER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) err_free_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) gpio_free(NET2BIG_GPIO_SATA0_POWER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^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) * GPIO LEDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * The power front LEDs (blue and red) and SATA red LEDs are controlled via a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * single GPIO line and are compatible with the leds-gpio driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * The SATA blue LEDs have some hardware blink capabilities which are detailed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * in the following array:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * SATAx blue LED | SATAx activity | LED state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * 0 | 0 | blink (rate 300ms)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * 1 | 0 | off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * ? | 1 | on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * Notes: The blue and the red front LED's can't be on at the same time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) * Blue LED have priority.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) #define NET2BIG_GPIO_PWR_RED_LED 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) #define NET2BIG_GPIO_PWR_BLUE_LED 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) #define NET2BIG_GPIO_PWR_LED_BLINK_STOP 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) #define NET2BIG_GPIO_SATA0_RED_LED 11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) #define NET2BIG_GPIO_SATA1_RED_LED 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #define NET2BIG_GPIO_SATA0_BLUE_LED 17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) #define NET2BIG_GPIO_SATA1_BLUE_LED 13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) static struct gpio_led net2big_leds[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) .name = "net2big:red:power",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) .gpio = NET2BIG_GPIO_PWR_RED_LED,
^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) .name = "net2big:blue:power",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) .gpio = NET2BIG_GPIO_PWR_BLUE_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) .name = "net2big:red:sata0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) .gpio = NET2BIG_GPIO_SATA0_RED_LED,
^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) .name = "net2big:red:sata1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) .gpio = NET2BIG_GPIO_SATA1_RED_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) },
^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) static struct gpio_led_platform_data net2big_led_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) .num_leds = ARRAY_SIZE(net2big_leds),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) .leds = net2big_leds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static struct platform_device net2big_gpio_leds = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) .name = "leds-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) .id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) .platform_data = &net2big_led_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static void __init net2big_gpio_leds_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) /* Stop initial CPLD slow red/blue blinking on power LED. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) err = gpio_request(NET2BIG_GPIO_PWR_LED_BLINK_STOP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) "Power LED blink stop");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) if (err == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) err = gpio_direction_output(NET2BIG_GPIO_PWR_LED_BLINK_STOP, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) gpio_free(NET2BIG_GPIO_PWR_LED_BLINK_STOP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) pr_err("net2big: failed to setup power LED blink GPIO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) * Configure SATA0 and SATA1 blue LEDs to blink in relation with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) * hard disk activity.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) err = gpio_request(NET2BIG_GPIO_SATA0_BLUE_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) "SATA0 blue LED control");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (err == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) err = gpio_direction_output(NET2BIG_GPIO_SATA0_BLUE_LED, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) gpio_free(NET2BIG_GPIO_SATA0_BLUE_LED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) pr_err("net2big: failed to setup SATA0 blue LED GPIO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) err = gpio_request(NET2BIG_GPIO_SATA1_BLUE_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) "SATA1 blue LED control");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if (err == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) err = gpio_direction_output(NET2BIG_GPIO_SATA1_BLUE_LED, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) gpio_free(NET2BIG_GPIO_SATA1_BLUE_LED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) pr_err("net2big: failed to setup SATA1 blue LED GPIO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) platform_device_register(&net2big_gpio_leds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) /****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) * GPIO keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) #define NET2BIG_GPIO_PUSH_BUTTON 18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) #define NET2BIG_GPIO_POWER_SWITCH_ON 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) #define NET2BIG_GPIO_POWER_SWITCH_OFF 9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) #define NET2BIG_SWITCH_POWER_ON 0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) #define NET2BIG_SWITCH_POWER_OFF 0x2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) static struct gpio_keys_button net2big_buttons[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) .type = EV_SW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) .code = NET2BIG_SWITCH_POWER_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) .gpio = NET2BIG_GPIO_POWER_SWITCH_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) .desc = "Power rocker switch (auto|off)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) .active_low = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) .type = EV_SW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) .code = NET2BIG_SWITCH_POWER_ON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) .gpio = NET2BIG_GPIO_POWER_SWITCH_ON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) .desc = "Power rocker switch (on|auto)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) .active_low = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) .type = EV_KEY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) .code = KEY_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) .gpio = NET2BIG_GPIO_PUSH_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) .desc = "Front Push Button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) .active_low = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) static struct gpio_keys_platform_data net2big_button_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) .buttons = net2big_buttons,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) .nbuttons = ARRAY_SIZE(net2big_buttons),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) static struct platform_device net2big_gpio_buttons = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) .name = "gpio-keys",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) .id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) .platform_data = &net2big_button_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) * General Setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) static unsigned int net2big_mpp_modes[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) MPP0_GPIO, /* Raid mode (bit 0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) MPP1_GPIO, /* USB port 2 fuse (0 = Fail, 1 = Ok) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) MPP2_GPIO, /* Raid mode (bit 1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) MPP3_GPIO, /* Board ID (bit 0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) MPP4_GPIO, /* Fan activity (0 = Off, 1 = On) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) MPP5_GPIO, /* Fan fail detection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) MPP6_GPIO, /* Red front LED (0 = Off, 1 = On) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) MPP7_GPIO, /* Disable initial blinking on front LED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) MPP8_GPIO, /* Rear power switch (on|auto) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) MPP9_GPIO, /* Rear power switch (auto|off) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) MPP10_GPIO, /* SATA 1 red LED (0 = Off, 1 = On) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) MPP11_GPIO, /* SATA 0 red LED (0 = Off, 1 = On) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) MPP12_GPIO, /* Board ID (bit 1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) MPP13_GPIO, /* SATA 1 blue LED blink control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) MPP14_SATA_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) MPP15_SATA_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) MPP16_GPIO, /* Blue front LED control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) MPP17_GPIO, /* SATA 0 blue LED blink control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) MPP18_GPIO, /* Front button (0 = Released, 1 = Pushed ) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) MPP19_GPIO, /* SATA{0,1} power On/Off request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) /* 22: USB port 1 fuse (0 = Fail, 1 = Ok) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) /* 23: SATA 0 power status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) /* 24: Board power off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) /* 25: SATA 1 power status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) #define NET2BIG_GPIO_POWER_OFF 24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) static void net2big_power_off(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) gpio_set_value(NET2BIG_GPIO_POWER_OFF, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) static void __init net2big_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) * Setup basic Orion functions. Need to be called early.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) orion5x_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) orion5x_mpp_conf(net2big_mpp_modes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) * Configure peripherals.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) orion5x_ehci0_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) orion5x_ehci1_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) orion5x_eth_init(&net2big_eth_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) orion5x_i2c_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) orion5x_uart0_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) orion5x_xor_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) net2big_sata_power_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) orion5x_sata_init(&net2big_sata_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) ORION_MBUS_DEVBUS_BOOT_ATTR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) NET2BIG_NOR_BOOT_BASE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) NET2BIG_NOR_BOOT_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) platform_device_register(&net2big_nor_flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) platform_device_register(&net2big_gpio_buttons);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) net2big_gpio_leds_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) i2c_register_board_info(0, net2big_i2c_devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) ARRAY_SIZE(net2big_i2c_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) orion_gpio_set_valid(NET2BIG_GPIO_POWER_OFF, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) if (gpio_request(NET2BIG_GPIO_POWER_OFF, "power-off") == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) gpio_direction_output(NET2BIG_GPIO_POWER_OFF, 0) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) pm_power_off = net2big_power_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) pr_err("net2big: failed to configure power-off GPIO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) pr_notice("net2big: Flash writing is not yet supported.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) /* Warning: LaCie use a wrong mach-type (0x20e=526) in their bootloader. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) MACHINE_START(NET2BIG, "LaCie 2Big Network")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) .atag_offset = 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) .nr_irqs = ORION5X_NR_IRQS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) .init_machine = net2big_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) .map_io = orion5x_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) .init_early = orion5x_init_early,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) .init_irq = orion5x_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) .init_time = orion5x_timer_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) .fixup = tag_fixup_mem32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) .restart = orion5x_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) MACHINE_END
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)