Advertisement
xerpi

3ds printk mod

Nov 27th, 2015
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.43 KB | None | 0 0
  1. #include <linux/kernel.h>
  2. #include <linux/init.h>
  3. #include <linux/io.h>
  4. #include <linux/irqchip/arm-gic.h>
  5. #include <linux/platform_device.h>
  6.  
  7. #include <linux/clk-provider.h>
  8. #include <linux/dma-mapping.h>
  9. #include <linux/init.h>
  10. #include <linux/of.h>
  11. #include <linux/of_platform.h>
  12. #include <linux/platform_device.h>
  13.  
  14. #include <linux/tty.h>
  15. #include <linux/tty_flip.h>
  16.  
  17. #include <linux/vt_kern.h>
  18. #include <linux/console_struct.h>
  19.  
  20. #include <asm/mach-types.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/mach/map.h>
  23. #include <asm/smp_twd.h>
  24.  
  25. #include <mach/hardware.h>
  26. #include <mach/platform.h>
  27.  
  28. /*
  29. static struct map_desc nintendo3ds_ctr_io_desc[] __initdata = {
  30.     {
  31.         .virtual    = IO_ADDRESS(NINTENDO3DS_CTR_PRIV_MEM_BASE),
  32.         .pfn        = __phys_to_pfn(NINTENDO3DS_CTR_PRIV_MEM_BASE),
  33.         .length     = NINTENDO3DS_CTR_PRIV_MEM_SIZE,
  34.         .type       = MT_DEVICE,
  35.     }
  36. };*/
  37.  
  38.  
  39. /*
  40. static void __init nintendo3ds_ctr_init_irq(void)
  41. {
  42.     int i;
  43.  
  44.     printk("nintendo3ds_ctr_init_irq\n");
  45.  
  46.     // Enable clear all the GID interrupts
  47.     // Pending clear all the GID interrupts
  48.     for (i = 0; i < 8; i++) {
  49.         writel(0xFFFFFFFF, __io_address(NINTENDO3DS_CTR_GIC_INT_PEND_CLR_REG(i)));
  50.         writel(0xFFFFFFFF, __io_address(NINTENDO3DS_CTR_GIC_INT_EN_CLR_REG(i)));
  51.     }
  52.  
  53.     gic_init(0, 29, __io_address(NINTENDO3DS_CTR_GIC_BASE),
  54.         __io_address(NINTENDO3DS_CTR_CPU_INT_INTERFACE_BASE));
  55.  
  56.     //printk("nintendo3ds_ctr_init_irq DONE\n");
  57.  
  58.     //gic_init(unsigned int nr, int start, void __iomem *dist , void __iomem *cpu)
  59.  
  60.     // Enable CPU Interrupt Interface
  61.     //writel(1, __io_address(NINTENDO3DS_CTR_CPU_INT_INTERFACE_CONTROL));
  62.  
  63.     // Enable Global Interrupt Distributor
  64.     //writel(1, __io_address(NINTENDO3DS_CTR_GID_IDCR));
  65. }*/
  66.  
  67. static void __init nintendo3ds_ctr_map_io(void)
  68. {
  69.     printk("nintendo3ds_ctr_map_io\n");
  70.     //iotable_init(nintendo3ds_ctr_io_desc, ARRAY_SIZE(nintendo3ds_ctr_io_desc));
  71. }
  72.  
  73. static void __init nintendo3ds_ctr_init_early(void)
  74. {
  75. }
  76.  
  77. #define HID_PAD_PA   (0x10146000)
  78. #define HID_PAD_SIZE (4)
  79.  
  80. #define BUTTON_A      (1 << 0)
  81. #define BUTTON_B      (1 << 1)
  82. #define BUTTON_SELECT (1 << 2)
  83. #define BUTTON_START  (1 << 3)
  84. #define BUTTON_RIGHT  (1 << 4)
  85. #define BUTTON_LEFT   (1 << 5)
  86. #define BUTTON_UP     (1 << 6)
  87. #define BUTTON_DOWN   (1 << 7)
  88. #define BUTTON_R1     (1 << 8)
  89. #define BUTTON_L1     (1 << 9)
  90. #define BUTTON_X      (1 << 10)
  91. #define BUTTON_Y      (1 << 11)
  92.  
  93. #define BUTTON_PRESS(b) (~ioread32(hid_pad) & b)
  94.  
  95. static void *hid_pad = NULL;
  96.  
  97. static void __init nintendo3ds_ctr_dt_init_machine(void)
  98. {
  99.     printk("nintendo3ds_ctr_dt_init_machine\n");
  100.     of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  101.  
  102.  
  103.     /* Try to map VRAM */
  104.  
  105.     /*vram_va = ioremap(NINTENDO3DS_CTR_VRAM_BASE,
  106.         NINTENDO3DS_CTR_VRAM_SIZE);
  107.  
  108.     printk("VRAM mapped to: %p - %p\n", vram_va,
  109.         vram_va + NINTENDO3DS_CTR_VRAM_SIZE);
  110.  
  111.     if (vram_va) {
  112.         for (i = 0; i < 420*340*3*2; i+=4)
  113.             iowrite32(0xFFFFFFFF, vram_va + i);
  114.     }*/
  115.  
  116.     /* Try to map HID_PAD */
  117.     if (!request_mem_region(HID_PAD_PA, HID_PAD_SIZE, "N3DS_HID_PAD")) {
  118.         printk("HID_PAD region not available.\n");
  119.     } else {
  120.         hid_pad = ioremap_nocache(HID_PAD_PA, HID_PAD_SIZE);
  121.  
  122.         printk("HID_PAD mapped to: %p - %p\n", hid_pad,
  123.             hid_pad + HID_PAD_SIZE);
  124.     }
  125. }
  126.  
  127. int n3ds_can_continue(void)
  128. {
  129.     volatile int i, sum = 0;
  130.     if (hid_pad) {
  131.         while (!BUTTON_PRESS(BUTTON_A)) {
  132.             if (BUTTON_PRESS(BUTTON_UP)) {
  133.                 for (i = 0; i < MAX_NR_CONSOLES; i++) {
  134.                     if (vc_cons_allocated(i)) {
  135.                         scrollback(vc_cons[i].d, 0);
  136.                         //tty_schedule_flip(&vc_cons[i].d->port);
  137.                         //tty_insert_flip_char(&vc_cons[i].d->port, 65, 0);
  138.                     }
  139.                 }
  140.             } else if (BUTTON_PRESS(BUTTON_DOWN)) {
  141.                 for (i = 0; i < MAX_NR_CONSOLES; i++) {
  142.                     if (vc_cons_allocated(i)) {
  143.                         scrollfront(vc_cons[i].d, 0);
  144.                         //tty_schedule_flip(&vc_cons[i].d->port);
  145.                     }
  146.                 }
  147.             }
  148.         }
  149.         for (i = 0; i < 1000000; i++)
  150.             sum += i;
  151.         return 1;
  152.     }
  153.     return 1;
  154. }
  155.  
  156. static void __init nintendo3ds_ctr_restart(enum reboot_mode mode, const char *cmd)
  157. {
  158.     printk("nintendo3ds_ctr_restart\n");
  159. }
  160.  
  161.  
  162. static const char *nintendo3ds_ctr_dt_platform_compat[] __initconst = {
  163.     "nintendo3ds,ctr",
  164.     NULL,
  165. };
  166.  
  167. DT_MACHINE_START(NINTENDO3DS_DT, "Nintendo 3DS (CTR) (Device Tree)")
  168.     .map_io     = nintendo3ds_ctr_map_io,
  169.     .init_early = nintendo3ds_ctr_init_early,
  170.     .init_machine   = nintendo3ds_ctr_dt_init_machine,
  171.     .dt_compat  = nintendo3ds_ctr_dt_platform_compat,
  172.     .restart    = nintendo3ds_ctr_restart,
  173. MACHINE_END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement