brcmnand.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright © 2015 Broadcom Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __BRCMNAND_H__
  14. #define __BRCMNAND_H__
  15. #include <linux/types.h>
  16. #include <linux/io.h>
  17. struct platform_device;
  18. struct dev_pm_ops;
  19. struct brcmnand_soc {
  20. bool (*ctlrdy_ack)(struct brcmnand_soc *soc);
  21. void (*ctlrdy_set_enabled)(struct brcmnand_soc *soc, bool en);
  22. void (*prepare_data_bus)(struct brcmnand_soc *soc, bool prepare,
  23. bool is_param);
  24. };
  25. static inline void brcmnand_soc_data_bus_prepare(struct brcmnand_soc *soc,
  26. bool is_param)
  27. {
  28. if (soc && soc->prepare_data_bus)
  29. soc->prepare_data_bus(soc, true, is_param);
  30. }
  31. static inline void brcmnand_soc_data_bus_unprepare(struct brcmnand_soc *soc,
  32. bool is_param)
  33. {
  34. if (soc && soc->prepare_data_bus)
  35. soc->prepare_data_bus(soc, false, is_param);
  36. }
  37. static inline u32 brcmnand_readl(void __iomem *addr)
  38. {
  39. /*
  40. * MIPS endianness is configured by boot strap, which also reverses all
  41. * bus endianness (i.e., big-endian CPU + big endian bus ==> native
  42. * endian I/O).
  43. *
  44. * Other architectures (e.g., ARM) either do not support big endian, or
  45. * else leave I/O in little endian mode.
  46. */
  47. if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
  48. return __raw_readl(addr);
  49. else
  50. return readl_relaxed(addr);
  51. }
  52. static inline void brcmnand_writel(u32 val, void __iomem *addr)
  53. {
  54. /* See brcmnand_readl() comments */
  55. if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
  56. __raw_writel(val, addr);
  57. else
  58. writel_relaxed(val, addr);
  59. }
  60. int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc);
  61. int brcmnand_remove(struct platform_device *pdev);
  62. extern const struct dev_pm_ops brcmnand_pm_ops;
  63. #endif /* __BRCMNAND_H__ */