Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * arch/arm/mach-orion5x/ls_hgl-setup.c
0004  *
0005  * Maintainer: Zhu Qingsen <zhuqs@cn.fujitsu.com>
0006  */
0007 
0008 #include <linux/kernel.h>
0009 #include <linux/init.h>
0010 #include <linux/platform_device.h>
0011 #include <linux/mtd/physmap.h>
0012 #include <linux/mv643xx_eth.h>
0013 #include <linux/leds.h>
0014 #include <linux/gpio_keys.h>
0015 #include <linux/input.h>
0016 #include <linux/i2c.h>
0017 #include <linux/ata_platform.h>
0018 #include <linux/gpio.h>
0019 #include <asm/mach-types.h>
0020 #include <asm/mach/arch.h>
0021 #include "common.h"
0022 #include "mpp.h"
0023 #include "orion5x.h"
0024 
0025 /*****************************************************************************
0026  * Linkstation LS-HGL Info
0027  ****************************************************************************/
0028 
0029 /*
0030  * 256K NOR flash Device bus boot chip select
0031  */
0032 
0033 #define LS_HGL_NOR_BOOT_BASE    0xf4000000
0034 #define LS_HGL_NOR_BOOT_SIZE    SZ_256K
0035 
0036 /*****************************************************************************
0037  * 256KB NOR Flash on BOOT Device
0038  ****************************************************************************/
0039 
0040 static struct physmap_flash_data ls_hgl_nor_flash_data = {
0041     .width      = 1,
0042 };
0043 
0044 static struct resource ls_hgl_nor_flash_resource = {
0045     .flags  = IORESOURCE_MEM,
0046     .start  = LS_HGL_NOR_BOOT_BASE,
0047     .end    = LS_HGL_NOR_BOOT_BASE + LS_HGL_NOR_BOOT_SIZE - 1,
0048 };
0049 
0050 static struct platform_device ls_hgl_nor_flash = {
0051     .name           = "physmap-flash",
0052     .id         = 0,
0053     .dev        = {
0054         .platform_data  = &ls_hgl_nor_flash_data,
0055     },
0056     .num_resources      = 1,
0057     .resource       = &ls_hgl_nor_flash_resource,
0058 };
0059 
0060 /*****************************************************************************
0061  * Ethernet
0062  ****************************************************************************/
0063 
0064 static struct mv643xx_eth_platform_data ls_hgl_eth_data = {
0065     .phy_addr   = 8,
0066 };
0067 
0068 /*****************************************************************************
0069  * RTC 5C372a on I2C bus
0070  ****************************************************************************/
0071 
0072 static struct i2c_board_info __initdata ls_hgl_i2c_rtc = {
0073     I2C_BOARD_INFO("rs5c372a", 0x32),
0074 };
0075 
0076 /*****************************************************************************
0077  * LEDs attached to GPIO
0078  ****************************************************************************/
0079 
0080 #define LS_HGL_GPIO_LED_ALARM   2
0081 #define LS_HGL_GPIO_LED_INFO    3
0082 #define LS_HGL_GPIO_LED_FUNC    17
0083 #define LS_HGL_GPIO_LED_PWR     0
0084 
0085 
0086 static struct gpio_led ls_hgl_led_pins[] = {
0087     {
0088         .name      = "alarm:red",
0089         .gpio      = LS_HGL_GPIO_LED_ALARM,
0090         .active_low     = 1,
0091     }, {
0092         .name      = "info:amber",
0093         .gpio      = LS_HGL_GPIO_LED_INFO,
0094         .active_low     = 1,
0095     }, {
0096         .name      = "func:blue:top",
0097         .gpio      = LS_HGL_GPIO_LED_FUNC,
0098         .active_low     = 1,
0099     }, {
0100         .name      = "power:blue:bottom",
0101         .gpio      = LS_HGL_GPIO_LED_PWR,
0102     },
0103 };
0104 
0105 static struct gpio_led_platform_data ls_hgl_led_data = {
0106     .leds      = ls_hgl_led_pins,
0107     .num_leds       = ARRAY_SIZE(ls_hgl_led_pins),
0108 };
0109 
0110 static struct platform_device ls_hgl_leds = {
0111     .name   = "leds-gpio",
0112     .id     = -1,
0113     .dev    = {
0114         .platform_data  = &ls_hgl_led_data,
0115     },
0116 };
0117 
0118 /****************************************************************************
0119  * GPIO Attached Keys
0120  ****************************************************************************/
0121 #define LS_HGL_GPIO_KEY_FUNC       15
0122 #define LS_HGL_GPIO_KEY_POWER      8
0123 #define LS_HGL_GPIO_KEY_AUTOPOWER  10
0124 
0125 #define LS_HGL_SW_POWER     0x00
0126 #define LS_HGL_SW_AUTOPOWER 0x01
0127 
0128 static struct gpio_keys_button ls_hgl_buttons[] = {
0129     {
0130         .code      = KEY_OPTION,
0131         .gpio      = LS_HGL_GPIO_KEY_FUNC,
0132         .desc      = "Function Button",
0133         .active_low     = 1,
0134     }, {
0135         .type       = EV_SW,
0136         .code      = LS_HGL_SW_POWER,
0137         .gpio      = LS_HGL_GPIO_KEY_POWER,
0138         .desc      = "Power-on Switch",
0139         .active_low     = 1,
0140     }, {
0141         .type       = EV_SW,
0142         .code      = LS_HGL_SW_AUTOPOWER,
0143         .gpio      = LS_HGL_GPIO_KEY_AUTOPOWER,
0144         .desc      = "Power-auto Switch",
0145         .active_low     = 1,
0146     },
0147 };
0148 
0149 static struct gpio_keys_platform_data ls_hgl_button_data = {
0150     .buttons    = ls_hgl_buttons,
0151     .nbuttons       = ARRAY_SIZE(ls_hgl_buttons),
0152 };
0153 
0154 static struct platform_device ls_hgl_button_device = {
0155     .name      = "gpio-keys",
0156     .id      = -1,
0157     .num_resources  = 0,
0158     .dev        = {
0159         .platform_data  = &ls_hgl_button_data,
0160     },
0161 };
0162 
0163 
0164 /*****************************************************************************
0165  * SATA
0166  ****************************************************************************/
0167 static struct mv_sata_platform_data ls_hgl_sata_data = {
0168     .n_ports    = 2,
0169 };
0170 
0171 
0172 /*****************************************************************************
0173  * Linkstation LS-HGL specific power off method: reboot
0174  ****************************************************************************/
0175 /*
0176  * On the Linkstation LS-HGL, the shutdown process is following:
0177  * - Userland monitors key events until the power switch goes to off position
0178  * - The board reboots
0179  * - U-boot starts and goes into an idle mode waiting for the user
0180  *   to move the switch to ON position
0181  */
0182 
0183 static void ls_hgl_power_off(void)
0184 {
0185     orion5x_restart(REBOOT_HARD, NULL);
0186 }
0187 
0188 
0189 /*****************************************************************************
0190  * General Setup
0191  ****************************************************************************/
0192 
0193 #define LS_HGL_GPIO_USB_POWER   9
0194 #define LS_HGL_GPIO_AUTO_POWER  10
0195 #define LS_HGL_GPIO_POWER       8
0196 
0197 #define LS_HGL_GPIO_HDD_POWER   1
0198 
0199 static unsigned int ls_hgl_mpp_modes[] __initdata = {
0200     MPP0_GPIO, /* LED_PWR */
0201     MPP1_GPIO, /* HDD_PWR */
0202     MPP2_GPIO, /* LED_ALARM */
0203     MPP3_GPIO, /* LED_INFO */
0204     MPP4_UNUSED,
0205     MPP5_UNUSED,
0206     MPP6_GPIO, /* FAN_LCK */
0207     MPP7_GPIO, /* INIT */
0208     MPP8_GPIO, /* POWER */
0209     MPP9_GPIO, /* USB_PWR */
0210     MPP10_GPIO, /* AUTO_POWER */
0211     MPP11_UNUSED, /* LED_ETH (dummy) */
0212     MPP12_UNUSED,
0213     MPP13_UNUSED,
0214     MPP14_UNUSED,
0215     MPP15_GPIO, /* FUNC */
0216     MPP16_UNUSED,
0217     MPP17_GPIO, /* LED_FUNC */
0218     MPP18_UNUSED,
0219     MPP19_UNUSED,
0220     0,
0221 };
0222 
0223 static void __init ls_hgl_init(void)
0224 {
0225     /*
0226      * Setup basic Orion functions. Need to be called early.
0227      */
0228     orion5x_init();
0229 
0230     orion5x_mpp_conf(ls_hgl_mpp_modes);
0231 
0232     /*
0233      * Configure peripherals.
0234      */
0235     orion5x_ehci0_init();
0236     orion5x_ehci1_init();
0237     orion5x_eth_init(&ls_hgl_eth_data);
0238     orion5x_i2c_init();
0239     orion5x_sata_init(&ls_hgl_sata_data);
0240     orion5x_uart0_init();
0241     orion5x_xor_init();
0242 
0243     mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
0244                     ORION_MBUS_DEVBUS_BOOT_ATTR,
0245                     LS_HGL_NOR_BOOT_BASE,
0246                     LS_HGL_NOR_BOOT_SIZE);
0247     platform_device_register(&ls_hgl_nor_flash);
0248 
0249     platform_device_register(&ls_hgl_button_device);
0250 
0251     platform_device_register(&ls_hgl_leds);
0252 
0253     i2c_register_board_info(0, &ls_hgl_i2c_rtc, 1);
0254 
0255     /* enable USB power */
0256     gpio_set_value(LS_HGL_GPIO_USB_POWER, 1);
0257 
0258     /* register power-off method */
0259     pm_power_off = ls_hgl_power_off;
0260 
0261     pr_info("%s: finished\n", __func__);
0262 }
0263 
0264 MACHINE_START(LINKSTATION_LS_HGL, "Buffalo Linkstation LS-HGL")
0265     /* Maintainer: Zhu Qingsen <zhuqs@cn.fujistu.com> */
0266     .atag_offset    = 0x100,
0267     .nr_irqs    = ORION5X_NR_IRQS,
0268     .init_machine   = ls_hgl_init,
0269     .map_io     = orion5x_map_io,
0270     .init_early = orion5x_init_early,
0271     .init_irq   = orion5x_init_irq,
0272     .init_time  = orion5x_timer_init,
0273     .fixup      = tag_fixup_mem32,
0274     .restart    = orion5x_restart,
0275 MACHINE_END