13 #include <linux/kernel.h>
14 #include <linux/types.h>
16 #include <linux/string.h>
17 #include <linux/module.h>
22 #include <linux/serial_core.h>
25 #include <linux/device.h>
26 #include <linux/slab.h>
28 #include <asm/bootinfo.h>
30 #include <asm/reboot.h>
32 #include <asm/sections.h>
38 #ifdef CONFIG_CPU_TX49XX
44 static char txx9_ce_res_name[8][4];
49 static struct resource txx9_reg_res = {
59 sprintf(txx9_ce_res_name[i],
"CE%d", i);
67 txx9_reg_res.
start = base & 0xfffffffffULL;
68 txx9_reg_res.
end = (base & 0xfffffffffULL) + (size - 1);
78 #ifdef CONFIG_CPU_TX39XX
89 if (!
strcmp(
id,
"spi-baseclk"))
91 if (!
strcmp(
id,
"imbus_clk"))
110 return (
unsigned long)clk;
121 #ifdef CONFIG_GENERIC_GPIO
135 #define BOARD_VEC(board) extern struct txx9_board_vec board;
140 static char txx9_system_type[32];
143 #define BOARD_VEC(board) &board,
153 for (i = 0; i <
ARRAY_SIZE(board_vecs); i++) {
155 return board_vecs[i];
180 for (i = 1; i <
argc; i++) {
181 char *
str = (
char *)(
long)argv32[
i];
196 #if defined(CONFIG_CPU_TX49XX)
198 static void __init early_flush_dcache(
void)
202 unsigned int linesz = 32;
215 static void __init txx9_cache_fixup(
void)
221 if (txx9_ic_disable) {
225 if (txx9_dc_disable) {
226 early_flush_dcache();
233 if (!txx9_ic_disable)
235 if (!txx9_dc_disable)
240 pr_info(
"TX49XX I-Cache disabled.\n");
242 pr_info(
"TX49XX D-Cache disabled.\n");
244 #elif defined(CONFIG_CPU_TX39XX)
246 static void __init early_flush_dcache(
void)
251 unsigned int linesz = 16;
262 static void __init txx9_cache_fixup(
void)
268 if (txx9_ic_disable) {
272 if (txx9_dc_disable) {
273 early_flush_dcache();
280 if (!txx9_ic_disable)
282 if (!txx9_dc_disable)
287 pr_info(
"TX39XX I-Cache disabled.\n");
289 pr_info(
"TX39XX D-Cache disabled.\n");
292 static inline void txx9_cache_fixup(
void)
297 static void __init preprocess_cmdline(
void)
306 char *str =
strsep(&s,
" ");
307 if (
strncmp(str,
"board=", 6) == 0) {
310 }
else if (
strncmp(str,
"masterclk=", 10) == 0) {
315 }
else if (
strcmp(str,
"icdisable") == 0) {
318 }
else if (
strcmp(str,
"dcdisable") == 0) {
321 }
else if (
strcmp(str,
"toeoff") == 0) {
324 }
else if (
strcmp(str,
"toeon") == 0) {
336 static void __init select_board(
void)
352 #ifdef CONFIG_CPU_TX39XX
355 #ifdef CONFIG_CPU_TX49XX
357 #ifdef CONFIG_TOSHIBA_RBTX4927
365 #ifdef CONFIG_TOSHIBA_RBTX4938
370 #ifdef CONFIG_TOSHIBA_RBTX4939
382 preprocess_cmdline();
401 return txx9_system_type;
413 while (str[0] && str[1]) {
414 if (!
strcmp((
const char *)(
unsigned long)str[0], name))
415 return (
const char *)(
unsigned long)str[1];
421 static void __noreturn txx9_machine_halt(
void)
445 .end = base + 0x100 - 1,
448 platform_device_register_simple(
"txx9wdt", -1, &res, 1);
471 .end = base + 0x20 - 1,
478 platform_device_register_simple(
"spi_txx9", busid,
493 unsigned int line,
unsigned int sclk,
int nocts)
495 #ifdef CONFIG_SERIAL_TXX9
498 memset(&req, 0,
sizeof(req));
515 #ifdef CONFIG_EARLY_PRINTK
516 static void __init null_prom_putchar(
char c)
519 void (*txx9_prom_putchar)(
char c) __initdata = null_prom_putchar;
523 txx9_prom_putchar(c);
526 static void __iomem *early_txx9_sio_port;
528 static void __init early_txx9_sio_putchar(
char c)
530 #define TXX9_SICISR 0x0c
531 #define TXX9_SITFIFO 0x1c
532 #define TXX9_SICISR_TXALS 0x00000002
539 void __init txx9_sio_putchar_init(
unsigned long baseaddr)
541 early_txx9_sio_port =
ioremap(baseaddr, 0x24);
542 txx9_prom_putchar = early_txx9_sio_putchar;
572 #ifdef CONFIG_CPU_TX49XX
578 static int __init _txx9_arch_init(
void)
586 static int __init _txx9_device_init(
void)
607 #ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
608 static unsigned long __swizzle_addr_none(
unsigned long port)
616 #ifdef NEEDS_TXX9_IOSWABW
621 static u16 __mem_ioswabw_default(
volatile u16 *
a,
u16 x)
635 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
638 .end = addr + size - 1,
647 addr < 0x1fc00000 && addr + size > 0x1fc00000 &&
649 parts[0].
name =
"boot";
651 parts[0].
size = addr + size - 0x1fc00000;
652 parts[1].
name =
"user";
673 #if IS_ENABLED(CONFIG_MTD_NAND_TXX9NDFMC)
676 .end = baseaddr + 0x1000 - 1,
689 #if IS_ENABLED(CONFIG_LEDS_GPIO)
692 #define TXX9_IOCLED_MAXLEDS 8
694 struct txx9_iocled_data {
695 struct gpio_chip
chip;
699 struct gpio_led leds[TXX9_IOCLED_MAXLEDS];
700 char names[TXX9_IOCLED_MAXLEDS][32];
703 static int txx9_iocled_get(
struct gpio_chip *
chip,
unsigned int offset)
705 struct txx9_iocled_data *
data =
707 return data->cur_val & (1 <<
offset);
710 static void txx9_iocled_set(
struct gpio_chip *
chip,
unsigned int offset,
713 struct txx9_iocled_data *
data =
718 data->cur_val |= 1 <<
offset;
720 data->cur_val &= ~(1 <<
offset);
721 writeb(data->cur_val, data->mmioaddr);
723 spin_unlock_irqrestore(&txx9_iocled_lock, flags);
726 static int txx9_iocled_dir_in(
struct gpio_chip *chip,
unsigned int offset)
731 static int txx9_iocled_dir_out(
struct gpio_chip *chip,
unsigned int offset,
734 txx9_iocled_set(chip, offset, value);
739 int basenum,
unsigned int num,
int lowactive,
740 const char *
color,
char **deftriggers)
742 struct txx9_iocled_data *iocled;
745 static char *default_triggers[] __initdata = {
753 deftriggers = default_triggers;
754 iocled = kzalloc(
sizeof(*iocled),
GFP_KERNEL);
757 iocled->mmioaddr =
ioremap(baseaddr, 1);
758 if (!iocled->mmioaddr)
760 iocled->chip.get = txx9_iocled_get;
761 iocled->chip.set = txx9_iocled_set;
762 iocled->chip.direction_input = txx9_iocled_dir_in;
763 iocled->chip.direction_output = txx9_iocled_dir_out;
764 iocled->chip.label =
"iocled";
765 iocled->chip.base = basenum;
766 iocled->chip.ngpio = num;
770 basenum = iocled->chip.base;
775 iocled->pdata.num_leds = num;
776 iocled->pdata.leds = iocled->leds;
777 for (i = 0; i < num; i++) {
779 snprintf(iocled->names[i],
sizeof(iocled->names[i]),
780 "iocled:%s:%u", color, i);
781 led->
name = iocled->names[
i];
782 led->
gpio = basenum +
i;
784 if (deftriggers && *deftriggers)
787 pdev->
dev.platform_data = &iocled->pdata;
803 int basenum,
unsigned int num,
int lowactive,
804 const char *color,
char **deftriggers)
812 #if IS_ENABLED(CONFIG_TXX9_DMAC)
816 .end = baseaddr + 0x800 - 1,
818 #ifndef CONFIG_MACH_TX49XX
825 #ifdef CONFIG_MACH_TX49XX
843 memset(&cpdata, 0,
sizeof(cpdata));
846 #ifdef CONFIG_MACH_TX49XX
847 chan_res[0].
start = irq +
i;
850 id * TXX9_DMA_MAX_NR_CHANNELS + i);
852 #ifdef CONFIG_MACH_TX49XX
864 unsigned int dmac_id,
865 unsigned int dma_chan_out,
866 unsigned int dma_chan_in)
868 #if IS_ENABLED(CONFIG_SND_SOC_TXX9ACLC)
873 .end = baseaddr + 0x100 - 1,
879 .name =
"txx9dmac-chan",
880 .start = dma_base + dma_chan_out,
883 .name =
"txx9dmac-chan",
884 .start = dma_base + dma_chan_in,
898 static struct bus_type txx9_sramc_subsys = {
900 .dev_name =
"txx9_sram",
914 size_t ramsize = bin_attr->
size;
918 if (pos + size > ramsize)
919 size = ramsize -
pos;
929 size_t ramsize = bin_attr->
size;
933 if (pos + size > ramsize)
934 size = ramsize -
pos;
951 size = resource_size(r);
955 dev->
dev.bus = &txx9_sramc_subsys;