1/* 2 * Bitmain Antminer S3 board support 3 * 4 * Copyright (C) 2015 L. D. Pinney <ldpinney@gmail.com> 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 as published 8 * by the Free Software Foundation. 9 */ 10 11#include <linux/gpio.h> 12 13#include <asm/mach-ath79/ath79.h> 14#include <asm/mach-ath79/ar71xx_regs.h> 15 16#include "common.h" 17#include "dev-eth.h" 18#include "dev-gpio-buttons.h" 19#include "dev-leds-gpio.h" 20#include "dev-m25p80.h" 21#include "dev-wmac.h" 22#include "machtypes.h" 23#include "dev-usb.h" 24 25#define ANTMINER_S3_GPIO_LED_WLAN 0 26#define ANTMINER_S3_GPIO_LED_SYSTEM 17 27#define ANTMINER_S3_GPIO_LED_LAN 22 28#define ANTMINER_S3_GPIO_USB_POWER 26 29 30#define ANTMINER_S3_GPIO_BTN_RESET 11 31 32#define ANTMINER_S3_KEYSPOLL_INTERVAL 88 /* msecs */ 33#define ANTMINER_S3_KEYSDEBOUNCE_INTERVAL (3 * ANTMINER_S3_KEYSPOLL_INTERVAL) 34 35static const char *ANTMINER_S3_part_probes[] = { 36 "tp-link", 37 NULL, 38}; 39 40static struct flash_platform_data ANTMINER_S3_flash_data = { 41 .part_probes = ANTMINER_S3_part_probes, 42}; 43 44static struct gpio_led ANTMINER_S3_leds_gpio[] __initdata = { 45 { 46 .name = "antminer-s3:green:wlan", 47 .gpio = ANTMINER_S3_GPIO_LED_WLAN, 48 .active_low = 0, 49 },{ 50 .name = "antminer-s3:green:system", 51 .gpio = ANTMINER_S3_GPIO_LED_SYSTEM, 52 .active_low = 0, 53 },{ 54 .name = "antminer-s3:yellow:lan", 55 .gpio = ANTMINER_S3_GPIO_LED_LAN, 56 .active_low = 0, 57 }, 58}; 59 60static struct gpio_keys_button ANTMINER_S3_GPIO_keys[] __initdata = { 61 { 62 .desc = "reset", 63 .type = EV_KEY, 64 .code = KEY_RESTART, 65 .debounce_interval = ANTMINER_S3_KEYSDEBOUNCE_INTERVAL, 66 .gpio = ANTMINER_S3_GPIO_BTN_RESET, 67 .active_low = 0, 68 }, 69}; 70 71static void __init antminer_s3_setup(void) 72{ 73 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00); 74 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); 75 76 /* disable PHY_SWAP and PHY_ADDR_SWAP bits */ 77 ath79_setup_ar933x_phy4_switch(false, false); 78 79 ath79_register_leds_gpio(-1, ARRAY_SIZE(ANTMINER_S3_leds_gpio), 80 ANTMINER_S3_leds_gpio); 81 82 ath79_register_gpio_keys_polled(-1, ANTMINER_S3_KEYSPOLL_INTERVAL, 83 ARRAY_SIZE(ANTMINER_S3_GPIO_keys), 84 ANTMINER_S3_GPIO_keys); 85 86 gpio_request_one(ANTMINER_S3_GPIO_USB_POWER, 87 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, 88 "USB power"); 89 ath79_register_usb(); 90 91 ath79_register_m25p80(&ANTMINER_S3_flash_data); 92 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1); 93 ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1); 94 95 ath79_register_mdio(0, 0x0); 96 ath79_register_eth(0); 97 ath79_register_eth(1); 98 99 ath79_register_wmac(ee, mac); 100} 101 102MIPS_MACHINE(ATH79_MACH_ANTMINER_S3, "ANTMINER-S3", 103 "Antminer-S3", antminer_s3_setup); 104