Path: blob/master/arch/arm/mach-kirkwood/tsx1x-common.c
10817 views
#include <linux/kernel.h>1#include <linux/pci.h>2#include <linux/platform_device.h>3#include <linux/mtd/physmap.h>4#include <linux/spi/flash.h>5#include <linux/spi/spi.h>6#include <linux/spi/orion_spi.h>7#include <linux/serial_reg.h>8#include <mach/kirkwood.h>9#include "common.h"1011/*12* QNAP TS-x1x Boards flash13*/1415/****************************************************************************16* 16 MiB NOR flash. The struct mtd_partition is not in the same order as the17* partitions on the device because we want to keep compatibility with18* the QNAP firmware.19* Layout as used by QNAP:20* 0x00000000-0x00080000 : "U-Boot"21* 0x00200000-0x00400000 : "Kernel"22* 0x00400000-0x00d00000 : "RootFS"23* 0x00d00000-0x01000000 : "RootFS2"24* 0x00080000-0x000c0000 : "U-Boot Config"25* 0x000c0000-0x00200000 : "NAS Config"26*27* We'll use "RootFS1" instead of "RootFS" to stay compatible with the layout28* used by the QNAP TS-109/TS-209.29*30***************************************************************************/3132struct mtd_partition qnap_tsx1x_partitions[] = {33{34.name = "U-Boot",35.size = 0x00080000,36.offset = 0,37.mask_flags = MTD_WRITEABLE,38}, {39.name = "Kernel",40.size = 0x00200000,41.offset = 0x00200000,42}, {43.name = "RootFS1",44.size = 0x00900000,45.offset = 0x00400000,46}, {47.name = "RootFS2",48.size = 0x00300000,49.offset = 0x00d00000,50}, {51.name = "U-Boot Config",52.size = 0x00040000,53.offset = 0x00080000,54}, {55.name = "NAS Config",56.size = 0x00140000,57.offset = 0x000c0000,58},59};6061const struct flash_platform_data qnap_tsx1x_flash = {62.type = "m25p128",63.name = "spi_flash",64.parts = qnap_tsx1x_partitions,65.nr_parts = ARRAY_SIZE(qnap_tsx1x_partitions),66};6768struct spi_board_info __initdata qnap_tsx1x_spi_slave_info[] = {69{70.modalias = "m25p80",71.platform_data = &qnap_tsx1x_flash,72.irq = -1,73.max_speed_hz = 20000000,74.bus_num = 0,75.chip_select = 0,76},77};7879void __init qnap_tsx1x_register_flash(void)80{81spi_register_board_info(qnap_tsx1x_spi_slave_info,82ARRAY_SIZE(qnap_tsx1x_spi_slave_info));83kirkwood_spi_init();84}858687/*****************************************************************************88* QNAP TS-x1x specific power off method via UART1-attached PIC89****************************************************************************/9091#define UART1_REG(x) (UART1_VIRT_BASE + ((UART_##x) << 2))9293void qnap_tsx1x_power_off(void)94{95/* 19200 baud divisor */96const unsigned divisor = ((kirkwood_tclk + (8 * 19200)) / (16 * 19200));9798pr_info("%s: triggering power-off...\n", __func__);99100/* hijack UART1 and reset into sane state (19200,8n1) */101writel(0x83, UART1_REG(LCR));102writel(divisor & 0xff, UART1_REG(DLL));103writel((divisor >> 8) & 0xff, UART1_REG(DLM));104writel(0x03, UART1_REG(LCR));105writel(0x00, UART1_REG(IER));106writel(0x00, UART1_REG(FCR));107writel(0x00, UART1_REG(MCR));108109/* send the power-off command 'A' to PIC */110writel('A', UART1_REG(TX));111}112113114115