13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <linux/slab.h>
16 #include <linux/export.h>
24 #include <asm/reboot.h>
29 static void rbtx4939_machine_restart(
char *
command)
38 static void __init rbtx4939_time_init(
void)
43 #if defined(__BIG_ENDIAN) && IS_ENABLED(CONFIG_SMC91X)
44 #define HAVE_RBTX4939_IOSWAB
45 #define IS_CE1_ADDR(addr) \
46 ((((unsigned long)(addr) - IO_BASE) & 0xfff00000) == TXX9_CE(1))
51 static u16 rbtx4939_mem_ioswabw(
volatile u16 *
a,
u16 x)
57 static void __init rbtx4939_pci_setup(
void)
82 static unsigned long long default_ebccr[]
__initdata = {
83 0x01c0000000007608ULL,
84 0x017f000000007049ULL,
85 0x0180000000408608ULL,
89 static void __init rbtx4939_ebusc_setup(
void)
96 default_ebccr[0] |=
sp;
97 default_ebccr[1] |=
sp;
98 default_ebccr[2] |=
sp;
100 for (i = 0; i <
ARRAY_SIZE(default_ebccr); i++) {
101 if (default_ebccr[i])
102 ____raw_writeq(default_ebccr[i],
111 static void __init rbtx4939_update_ioc_pen(
void)
187 #define RBTX4939_MAX_7SEGLEDS 8
189 #if IS_ENABLED(CONFIG_LEDS_CLASS)
191 struct rbtx4939_led_data {
198 static void rbtx4939_led_brightness_set(
struct led_classdev *led_cdev,
201 struct rbtx4939_led_data *led_dat =
203 unsigned int num = led_dat->num;
207 led_val[num] = (led_val[num] & 0x7f) | (value ? 0x80 : 0);
214 struct rbtx4939_led_data *leds_data;
216 static char *default_triggers[] __initdata = {
228 struct rbtx4939_led_data *led_dat = &leds_data[
i];
231 led_dat->cdev.brightness_set = rbtx4939_led_brightness_set;
232 sprintf(led_dat->name,
"rbtx4939:amber:%u", i);
233 led_dat->cdev.name = led_dat->name;
235 led_dat->cdev.default_trigger = default_triggers[
i];
239 led_dat->cdev.brightness_set(&led_dat->cdev, 0);
247 .name =
"rbtx4939-led",
252 static void __init rbtx4939_led_setup(
void)
254 platform_device_register_simple(
"rbtx4939-led", -1,
NULL, 0);
258 static inline void rbtx4939_led_setup(
void)
263 static void __rbtx4939_7segled_putc(
unsigned int pos,
unsigned char val)
265 #if IS_ENABLED(CONFIG_LEDS_CLASS)
269 led_val[
pos] = (led_val[
pos] & 0x80) | (val & 0x7f);
276 static void rbtx4939_7segled_putc(
unsigned int pos,
unsigned char val)
280 ((val & 0x40) >> 6) |
281 ((val & 0x20) >> 4) |
282 ((val & 0x10) >> 2) |
283 ((val & 0x04) << 2) |
284 ((val & 0x02) << 4) |
286 __rbtx4939_7segled_putc(pos, val);
289 #if IS_ENABLED(CONFIG_MTD_RBTX4939)
291 static unsigned long rbtx4939_flash_fixup_ofs(
unsigned long ofs)
300 return (ofs & ~0xc00000) | ((((ofs >> 22) + shift) & 3) << 22);
314 ofs = rbtx4939_flash_fixup_ofs(ofs);
322 ofs = rbtx4939_flash_fixup_ofs(ofs);
327 static void rbtx4939_flash_copy_from(
struct map_info *
map,
void *to,
339 curlen =
min_t(
unsigned long, len,
340 0x400000 - (from & (0x400000 - 1)));
342 (
void *)((from & ~0xc00000) |
343 ((((from >> 22) + shift) & 3) << 22)),
355 curlen =
min_t(
unsigned long, len,
356 0x400000 - (from & (0x400000 - 1)));
357 memcpy(to, (
void *)(from ^ 0x400000), curlen);
365 memcpy(to, (
void *)from, len);
368 static void rbtx4939_flash_map_init(
struct map_info *map)
370 map->read = rbtx4939_flash_read16;
371 map->write = rbtx4939_flash_write16;
372 map->copy_from = rbtx4939_flash_copy_from;
375 static void __init rbtx4939_mtd_init(
void)
383 static char names[4][8];
391 for (i = 0; i < boot_pdata->
nr_parts; i++) {
392 sprintf(names[i],
"img%d", 4 - i);
397 }
else if (bdipsw == 0) {
401 strcpy(names[1],
"little");
402 for (i = 0; i < boot_pdata->
nr_parts; i++) {
410 parts[0].name =
"boot";
411 parts[0].offset = 0xc00000;
412 parts[0].size = 0x400000;
413 parts[1].name =
"user";
415 parts[1].size = 0xc00000;
418 boot_pdata->
map_init = rbtx4939_flash_map_init;
424 r->
start = 0x1f000000 - i * 0x1000000;
427 pdevs[
i].data.width = 2;
431 dev->
name =
"rbtx4939-flash";
432 dev->
dev.platform_data = &pdevs[
i].data;
437 static void __init rbtx4939_mtd_init(
void)
442 static void __init rbtx4939_arch_init(
void)
444 rbtx4939_pci_setup();
447 static void __init rbtx4939_device_init(
void)
453 .end = smc_addr + 0x10 - 1,
465 #if IS_ENABLED(CONFIG_TC35815)
467 unsigned char ethaddr[2][6];
470 for (i = 0; i < 2; i++) {
471 unsigned long area =
CKSEG1 + 0x1fff0000 + (i * 0x10);
473 memcpy(ethaddr[i], (
void *)area, 6);
480 for (j = 0; j < 3; j++)
482 memcpy(ethaddr[i], buf, 6);
498 rbtx4939_led_setup();
504 platform_device_register_simple(
"txx9aclc-generic", -1,
NULL, 0);
509 static void __init rbtx4939_setup(
void)
513 rbtx4939_ebusc_setup();
519 rbtx4939_update_ioc_pen();
520 #ifdef HAVE_RBTX4939_IOSWAB
530 pr_info(
"RBTX4939 (Rev %02x) --- FPGA(Rev %02x) DIPSW:%02x,%02x\n",
545 .
system =
"Toshiba RBTX4939",
547 .mem_setup = rbtx4939_setup,
549 .time_init = rbtx4939_time_init,
550 .device_init = rbtx4939_device_init,
551 .arch_init = rbtx4939_arch_init,