setup.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * arch/sh/boards/landisk/setup.c
  4. *
  5. * I-O DATA Device, Inc. LANDISK Support.
  6. *
  7. * Copyright (C) 2000 Kazumoto Kojima
  8. * Copyright (C) 2002 Paul Mundt
  9. * Copylight (C) 2002 Atom Create Engineering Co., Ltd.
  10. * Copyright (C) 2005-2007 kogiidena
  11. */
  12. #include <linux/init.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/ata_platform.h>
  15. #include <linux/pm.h>
  16. #include <linux/mm.h>
  17. #include <asm/machvec.h>
  18. #include <mach-landisk/mach/iodata_landisk.h>
  19. #include <asm/io.h>
  20. static void landisk_power_off(void)
  21. {
  22. __raw_writeb(0x01, PA_SHUTDOWN);
  23. }
  24. static struct resource cf_ide_resources[3];
  25. static struct pata_platform_info pata_info = {
  26. .ioport_shift = 1,
  27. };
  28. static struct platform_device cf_ide_device = {
  29. .name = "pata_platform",
  30. .id = -1,
  31. .num_resources = ARRAY_SIZE(cf_ide_resources),
  32. .resource = cf_ide_resources,
  33. .dev = {
  34. .platform_data = &pata_info,
  35. },
  36. };
  37. static struct platform_device rtc_device = {
  38. .name = "rs5c313",
  39. .id = -1,
  40. };
  41. static struct platform_device *landisk_devices[] __initdata = {
  42. &cf_ide_device,
  43. &rtc_device,
  44. };
  45. static int __init landisk_devices_setup(void)
  46. {
  47. pgprot_t prot;
  48. unsigned long paddrbase;
  49. void *cf_ide_base;
  50. /* open I/O area window */
  51. paddrbase = virt_to_phys((void *)PA_AREA5_IO);
  52. prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16);
  53. cf_ide_base = ioremap_prot(paddrbase, PAGE_SIZE, pgprot_val(prot));
  54. if (!cf_ide_base) {
  55. printk("allocate_cf_area : can't open CF I/O window!\n");
  56. return -ENOMEM;
  57. }
  58. /* IDE cmd address : 0x1f0-0x1f7 and 0x3f6 */
  59. cf_ide_resources[0].start = (unsigned long)cf_ide_base + 0x40;
  60. cf_ide_resources[0].end = (unsigned long)cf_ide_base + 0x40 + 0x0f;
  61. cf_ide_resources[0].flags = IORESOURCE_IO;
  62. cf_ide_resources[1].start = (unsigned long)cf_ide_base + 0x2c;
  63. cf_ide_resources[1].end = (unsigned long)cf_ide_base + 0x2c + 0x03;
  64. cf_ide_resources[1].flags = IORESOURCE_IO;
  65. cf_ide_resources[2].start = IRQ_FATA;
  66. cf_ide_resources[2].flags = IORESOURCE_IRQ;
  67. return platform_add_devices(landisk_devices,
  68. ARRAY_SIZE(landisk_devices));
  69. }
  70. device_initcall(landisk_devices_setup);
  71. static void __init landisk_setup(char **cmdline_p)
  72. {
  73. /* I/O port identity mapping */
  74. __set_io_port_base(0);
  75. /* LED ON */
  76. __raw_writeb(__raw_readb(PA_LED) | 0x03, PA_LED);
  77. printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n");
  78. pm_power_off = landisk_power_off;
  79. }
  80. /*
  81. * The Machine Vector
  82. */
  83. static struct sh_machine_vector mv_landisk __initmv = {
  84. .mv_name = "LANDISK",
  85. .mv_setup = landisk_setup,
  86. .mv_init_irq = init_landisk_IRQ,
  87. };