simtec-nor.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2008 Simtec Electronics
  4. // http://armlinux.simtec.co.uk/
  5. // Ben Dooks <[email protected]>
  6. //
  7. // Simtec NOR mapping
  8. #include <linux/module.h>
  9. #include <linux/types.h>
  10. #include <linux/init.h>
  11. #include <linux/kernel.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/mtd.h>
  14. #include <linux/mtd/map.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <linux/mtd/partitions.h>
  17. #include <asm/mach/arch.h>
  18. #include <asm/mach/map.h>
  19. #include <asm/mach/irq.h>
  20. #include "map.h"
  21. #include "bast.h"
  22. #include "simtec.h"
  23. static void simtec_nor_vpp(struct platform_device *pdev, int vpp)
  24. {
  25. unsigned int val;
  26. val = __raw_readb(BAST_VA_CTRL3);
  27. printk(KERN_DEBUG "%s(%d)\n", __func__, vpp);
  28. if (vpp)
  29. val |= BAST_CPLD_CTRL3_ROMWEN;
  30. else
  31. val &= ~BAST_CPLD_CTRL3_ROMWEN;
  32. __raw_writeb(val, BAST_VA_CTRL3);
  33. }
  34. static struct physmap_flash_data simtec_nor_pdata = {
  35. .width = 2,
  36. .set_vpp = simtec_nor_vpp,
  37. .nr_parts = 0,
  38. };
  39. static struct resource simtec_nor_resource[] = {
  40. [0] = DEFINE_RES_MEM(S3C2410_CS1 + 0x4000000, SZ_8M),
  41. };
  42. static struct platform_device simtec_device_nor = {
  43. .name = "physmap-flash",
  44. .id = -1,
  45. .num_resources = ARRAY_SIZE(simtec_nor_resource),
  46. .resource = simtec_nor_resource,
  47. .dev = {
  48. .platform_data = &simtec_nor_pdata,
  49. },
  50. };
  51. void __init nor_simtec_init(void)
  52. {
  53. int ret;
  54. ret = platform_device_register(&simtec_device_nor);
  55. if (ret < 0)
  56. printk(KERN_ERR "failed to register physmap-flash device\n");
  57. else
  58. simtec_nor_vpp(NULL, 1);
  59. }