nor-simtec.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <mach/map.h>
  26. #include <mach/bast-map.h>
  27. #include <mach/bast-cpld.h>
  28. #include "nor-simtec.h"
  29. static void simtec_nor_vpp(struct map_info *map, int vpp)
  30. {
  31. unsigned int val;
  32. unsigned long flags;
  33. local_irq_save(flags);
  34. val = __raw_readb(BAST_VA_CTRL3);
  35. printk(KERN_DEBUG "%s(%d)\n", __func__, vpp);
  36. if (vpp)
  37. val |= BAST_CPLD_CTRL3_ROMWEN;
  38. else
  39. val &= ~BAST_CPLD_CTRL3_ROMWEN;
  40. __raw_writeb(val, BAST_VA_CTRL3);
  41. local_irq_restore(flags);
  42. }
  43. static struct physmap_flash_data simtec_nor_pdata = {
  44. .width = 2,
  45. .set_vpp = simtec_nor_vpp,
  46. .nr_parts = 0,
  47. };
  48. static struct resource simtec_nor_resource[] = {
  49. [0] = {
  50. .start = S3C2410_CS1 + 0x4000000,
  51. .end = S3C2410_CS1 + 0x4000000 + SZ_8M - 1,
  52. .flags = IORESOURCE_MEM,
  53. }
  54. };
  55. static struct platform_device simtec_device_nor = {
  56. .name = "physmap-flash",
  57. .id = -1,
  58. .num_resources = ARRAY_SIZE(simtec_nor_resource),
  59. .resource = simtec_nor_resource,
  60. .dev = {
  61. .platform_data = &simtec_nor_pdata,
  62. },
  63. };
  64. void __init nor_simtec_init(void)
  65. {
  66. int ret;
  67. ret = platform_device_register(&simtec_device_nor);
  68. if (ret < 0)
  69. printk(KERN_ERR "failed to register physmap-flash device\n");
  70. else
  71. simtec_nor_vpp(NULL, 1);
  72. }