~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-kirkwood/tsx1x-common.c

Version: ~ [ linux-5.13-rc5 ] ~ [ linux-5.12.9 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.42 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.124 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.193 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.235 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.271 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.271 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include <linux/kernel.h>
  2 #include <linux/pci.h>
  3 #include <linux/platform_device.h>
  4 #include <linux/mtd/physmap.h>
  5 #include <linux/spi/flash.h>
  6 #include <linux/spi/spi.h>
  7 #include <linux/serial_reg.h>
  8 #include <mach/kirkwood.h>
  9 #include "common.h"
 10 #include "tsx1x-common.h"
 11 
 12 /*
 13  * QNAP TS-x1x Boards flash
 14  */
 15 
 16 /****************************************************************************
 17  * 16 MiB NOR flash. The struct mtd_partition is not in the same order as the
 18  *     partitions on the device because we want to keep compatibility with
 19  *     the QNAP firmware.
 20  * Layout as used by QNAP:
 21  *  0x00000000-0x00080000 : "U-Boot"
 22  *  0x00200000-0x00400000 : "Kernel"
 23  *  0x00400000-0x00d00000 : "RootFS"
 24  *  0x00d00000-0x01000000 : "RootFS2"
 25  *  0x00080000-0x000c0000 : "U-Boot Config"
 26  *  0x000c0000-0x00200000 : "NAS Config"
 27  *
 28  * We'll use "RootFS1" instead of "RootFS" to stay compatible with the layout
 29  * used by the QNAP TS-109/TS-209.
 30  *
 31  ***************************************************************************/
 32 
 33 static struct mtd_partition qnap_tsx1x_partitions[] = {
 34         {
 35                 .name           = "U-Boot",
 36                 .size           = 0x00080000,
 37                 .offset         = 0,
 38                 .mask_flags     = MTD_WRITEABLE,
 39         }, {
 40                 .name           = "Kernel",
 41                 .size           = 0x00200000,
 42                 .offset         = 0x00200000,
 43         }, {
 44                 .name           = "RootFS1",
 45                 .size           = 0x00900000,
 46                 .offset         = 0x00400000,
 47         }, {
 48                 .name           = "RootFS2",
 49                 .size           = 0x00300000,
 50                 .offset         = 0x00d00000,
 51         }, {
 52                 .name           = "U-Boot Config",
 53                 .size           = 0x00040000,
 54                 .offset         = 0x00080000,
 55         }, {
 56                 .name           = "NAS Config",
 57                 .size           = 0x00140000,
 58                 .offset         = 0x000c0000,
 59         },
 60 };
 61 
 62 static const struct flash_platform_data qnap_tsx1x_flash = {
 63         .type           = "m25p128",
 64         .name           = "spi_flash",
 65         .parts          = qnap_tsx1x_partitions,
 66         .nr_parts       = ARRAY_SIZE(qnap_tsx1x_partitions),
 67 };
 68 
 69 static struct spi_board_info __initdata qnap_tsx1x_spi_slave_info[] = {
 70         {
 71                 .modalias       = "m25p80",
 72                 .platform_data  = &qnap_tsx1x_flash,
 73                 .irq            = -1,
 74                 .max_speed_hz   = 20000000,
 75                 .bus_num        = 0,
 76                 .chip_select    = 0,
 77         },
 78 };
 79 
 80 void __init qnap_tsx1x_register_flash(void)
 81 {
 82         spi_register_board_info(qnap_tsx1x_spi_slave_info,
 83                                 ARRAY_SIZE(qnap_tsx1x_spi_slave_info));
 84         kirkwood_spi_init();
 85 }
 86 
 87 
 88 /*****************************************************************************
 89  * QNAP TS-x1x specific power off method via UART1-attached PIC
 90  ****************************************************************************/
 91 
 92 #define UART1_REG(x)    (UART1_VIRT_BASE + ((UART_##x) << 2))
 93 
 94 void qnap_tsx1x_power_off(void)
 95 {
 96         /* 19200 baud divisor */
 97         const unsigned divisor = ((kirkwood_tclk + (8 * 19200)) / (16 * 19200));
 98 
 99         pr_info("%s: triggering power-off...\n", __func__);
100 
101         /* hijack UART1 and reset into sane state (19200,8n1) */
102         writel(0x83, UART1_REG(LCR));
103         writel(divisor & 0xff, UART1_REG(DLL));
104         writel((divisor >> 8) & 0xff, UART1_REG(DLM));
105         writel(0x03, UART1_REG(LCR));
106         writel(0x00, UART1_REG(IER));
107         writel(0x00, UART1_REG(FCR));
108         writel(0x00, UART1_REG(MCR));
109 
110         /* send the power-off command 'A' to PIC */
111         writel('A', UART1_REG(TX));
112 }
113 
114 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp