nor-simtec.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* linux/arch/arm/mach-s3c2410/nor-simtec.c
  2. *
  3. * Copyright (c) 2008 Simtec Electronics
  4. * http://armlinux.simtec.co.uk/
  5. * Ben Dooks <ben@simtec.co.uk>
  6. *
  7. * Simtec NOR mapping
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/types.h>
  15. #include <linux/init.h>
  16. #include <linux/kernel.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/mtd/mtd.h>
  19. #include <linux/mtd/map.h>
  20. #include <linux/mtd/physmap.h>
  21. #include <linux/mtd/partitions.h>
  22. #include <asm/mach/arch.h>
  23. #include <asm/mach/map.h>
  24. #include <asm/mach/irq.h>
  25. #include <asm/arch/map.h>
  26. #include <asm/arch/bast-map.h>
  27. #include <asm/arch/bast-cpld.h>
  28. static void simtec_nor_vpp(struct map_info *map, int vpp)
  29. {
  30. unsigned int val;
  31. unsigned long flags;
  32. local_irq_save(flags);
  33. val = __raw_readb(BAST_VA_CTRL3);
  34. printk(KERN_DEBUG "%s(%d)\n", __func__, vpp);
  35. if (vpp)
  36. val |= BAST_CPLD_CTRL3_ROMWEN;
  37. else
  38. val &= ~BAST_CPLD_CTRL3_ROMWEN;
  39. __raw_writeb(val, BAST_VA_CTRL3);
  40. local_irq_restore(flags);
  41. }
  42. struct physmap_flash_data simtec_nor_pdata = {
  43. .width = 2,
  44. .set_vpp = simtec_nor_vpp,
  45. .nr_parts = 0,
  46. };
  47. static struct resource simtec_nor_resource[] = {
  48. [0] = {
  49. .start = S3C2410_CS1 + 0x4000000,
  50. .end = S3C2410_CS1 + 0x4000000 + SZ_8M - 1,
  51. .flags = IORESOURCE_MEM,
  52. }
  53. };
  54. static struct platform_device simtec_device_nor = {
  55. .name = "physmap-flash",
  56. .id = -1,
  57. .num_resources = ARRAY_SIZE(simtec_nor_resource),
  58. .resource = simtec_nor_resource,
  59. .dev = {
  60. .platform_data = &simtec_nor_pdata,
  61. },
  62. };
  63. void __init nor_simtec_init(void)
  64. {
  65. int ret;
  66. ret = platform_device_register(&simtec_device_nor);
  67. if (ret < 0)
  68. printk(KERN_ERR "failed to register physmap-flash device\n");
  69. else
  70. simtec_nor_vpp(NULL, 1);
  71. }