2008-05-31 16:21:49 +00:00
|
|
|
/*
|
|
|
|
* QNAP TS-x09 Boards common functions
|
|
|
|
*
|
|
|
|
* Maintainers: Lennert Buytenhek <buytenh@marvell.com>
|
|
|
|
* Byron Bradley <byron.bbradley@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/mv643xx_eth.h>
|
2008-06-25 21:41:09 +00:00
|
|
|
#include <linux/timex.h>
|
2008-05-31 16:21:49 +00:00
|
|
|
#include <linux/serial_reg.h>
|
2015-12-02 21:27:08 +00:00
|
|
|
#include "orion5x.h"
|
2008-05-31 16:21:49 +00:00
|
|
|
#include "tsx09-common.h"
|
2008-08-29 03:55:51 +00:00
|
|
|
#include "common.h"
|
2008-05-31 16:21:49 +00:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* QNAP TS-x09 specific power off method via UART1-attached PIC
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#define UART1_REG(x) (UART1_VIRT_BASE + ((UART_##x) << 2))
|
|
|
|
|
|
|
|
void qnap_tsx09_power_off(void)
|
|
|
|
{
|
|
|
|
/* 19200 baud divisor */
|
2008-08-29 03:55:51 +00:00
|
|
|
const unsigned divisor = ((orion5x_tclk + (8 * 19200)) / (16 * 19200));
|
2008-05-31 16:21:49 +00:00
|
|
|
|
|
|
|
pr_info("%s: triggering power-off...\n", __func__);
|
|
|
|
|
|
|
|
/* hijack uart1 and reset into sane state (19200,8n1) */
|
|
|
|
writel(0x83, UART1_REG(LCR));
|
|
|
|
writel(divisor & 0xff, UART1_REG(DLL));
|
|
|
|
writel((divisor >> 8) & 0xff, UART1_REG(DLM));
|
|
|
|
writel(0x03, UART1_REG(LCR));
|
|
|
|
writel(0x00, UART1_REG(IER));
|
|
|
|
writel(0x00, UART1_REG(FCR));
|
|
|
|
writel(0x00, UART1_REG(MCR));
|
|
|
|
|
|
|
|
/* send the power-off command 'A' to PIC */
|
|
|
|
writel('A', UART1_REG(TX));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Ethernet
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct mv643xx_eth_platform_data qnap_tsx09_eth_data = {
|
2008-08-26 12:06:47 +00:00
|
|
|
.phy_addr = MV643XX_ETH_PHY_ADDR(8),
|
2008-05-31 16:21:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init qnap_tsx09_check_mac_addr(const char *addr_str)
|
|
|
|
{
|
|
|
|
u_int8_t addr[6];
|
|
|
|
|
2015-10-02 14:12:33 +00:00
|
|
|
if (!mac_pton(addr_str, addr))
|
|
|
|
return -1;
|
2008-05-31 16:21:49 +00:00
|
|
|
|
2015-06-15 02:01:30 +00:00
|
|
|
printk(KERN_INFO "tsx09: found ethernet mac address %pM\n", addr);
|
2008-05-31 16:21:49 +00:00
|
|
|
|
|
|
|
memcpy(qnap_tsx09_eth_data.mac_addr, addr, 6);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The 'NAS Config' flash partition has an ext2 filesystem which
|
|
|
|
* contains a file that has the ethernet MAC address in plain text
|
|
|
|
* (format "xx:xx:xx:xx:xx:xx\n").
|
|
|
|
*/
|
|
|
|
void __init qnap_tsx09_find_mac_addr(u32 mem_base, u32 size)
|
|
|
|
{
|
|
|
|
unsigned long addr;
|
|
|
|
|
|
|
|
for (addr = mem_base; addr < (mem_base + size); addr += 1024) {
|
2015-10-02 14:12:33 +00:00
|
|
|
void __iomem *nor_page;
|
2008-05-31 16:21:49 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
nor_page = ioremap(addr, 1024);
|
|
|
|
if (nor_page != NULL) {
|
2015-10-02 14:12:33 +00:00
|
|
|
ret = qnap_tsx09_check_mac_addr((__force const char *)nor_page);
|
2008-05-31 16:21:49 +00:00
|
|
|
iounmap(nor_page);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|