setup.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * KFR2R09 board support code
  3. *
  4. * Copyright (C) 2009 Magnus Damm
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/mtd/physmap.h>
  14. #include <linux/delay.h>
  15. #include <linux/clk.h>
  16. #include <linux/gpio.h>
  17. #include <asm/clock.h>
  18. #include <asm/machvec.h>
  19. #include <asm/io.h>
  20. #include <cpu/sh7724.h>
  21. static struct mtd_partition kfr2r09_nor_flash_partitions[] =
  22. {
  23. {
  24. .name = "boot",
  25. .offset = 0,
  26. .size = (4 * 1024 * 1024),
  27. .mask_flags = MTD_WRITEABLE, /* Read-only */
  28. },
  29. {
  30. .name = "other",
  31. .offset = MTDPART_OFS_APPEND,
  32. .size = MTDPART_SIZ_FULL,
  33. },
  34. };
  35. static struct physmap_flash_data kfr2r09_nor_flash_data = {
  36. .width = 2,
  37. .parts = kfr2r09_nor_flash_partitions,
  38. .nr_parts = ARRAY_SIZE(kfr2r09_nor_flash_partitions),
  39. };
  40. static struct resource kfr2r09_nor_flash_resources[] = {
  41. [0] = {
  42. .name = "NOR Flash",
  43. .start = 0x00000000,
  44. .end = 0x03ffffff,
  45. .flags = IORESOURCE_MEM,
  46. }
  47. };
  48. static struct platform_device kfr2r09_nor_flash_device = {
  49. .name = "physmap-flash",
  50. .resource = kfr2r09_nor_flash_resources,
  51. .num_resources = ARRAY_SIZE(kfr2r09_nor_flash_resources),
  52. .dev = {
  53. .platform_data = &kfr2r09_nor_flash_data,
  54. },
  55. };
  56. static struct platform_device *kfr2r09_devices[] __initdata = {
  57. &kfr2r09_nor_flash_device,
  58. };
  59. #define BSC_CS0BCR 0xfec10004
  60. #define BSC_CS0WCR 0xfec10024
  61. static int __init kfr2r09_devices_setup(void)
  62. {
  63. /* enable SCIF1 serial port for YC401 console support */
  64. gpio_request(GPIO_FN_SCIF1_RXD, NULL);
  65. gpio_request(GPIO_FN_SCIF1_TXD, NULL);
  66. /* setup NOR flash at CS0 */
  67. ctrl_outl(0x36db0400, BSC_CS0BCR);
  68. ctrl_outl(0x00000500, BSC_CS0WCR);
  69. return platform_add_devices(kfr2r09_devices,
  70. ARRAY_SIZE(kfr2r09_devices));
  71. }
  72. device_initcall(kfr2r09_devices_setup);
  73. /* Return the board specific boot mode pin configuration */
  74. static int kfr2r09_mode_pins(void)
  75. {
  76. /* MD0=1, MD1=1, MD2=0: Clock Mode 3
  77. * MD3=0: 16-bit Area0 Bus Width
  78. * MD5=1: Little Endian
  79. * MD8=1: Test Mode Disabled
  80. */
  81. return MODE_PIN0 | MODE_PIN1 | MODE_PIN5 | MODE_PIN8;
  82. }
  83. /*
  84. * The Machine Vector
  85. */
  86. static struct sh_machine_vector mv_kfr2r09 __initmv = {
  87. .mv_name = "kfr2r09",
  88. .mv_mode_pins = kfr2r09_mode_pins,
  89. };