162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * OMAP GPMC (General Purpose Memory Controller) defines 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <linux/platform_data/gpmc-omap.h> 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#define GPMC_CONFIG_WP 0x00000005 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci/* IRQ numbers in GPMC IRQ domain for legacy boot use */ 1162306a36Sopenharmony_ci#define GPMC_IRQ_FIFOEVENTENABLE 0 1262306a36Sopenharmony_ci#define GPMC_IRQ_COUNT_EVENT 1 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/** 1562306a36Sopenharmony_ci * gpmc_nand_ops - Interface between NAND and GPMC 1662306a36Sopenharmony_ci * @nand_write_buffer_empty: get the NAND write buffer empty status. 1762306a36Sopenharmony_ci */ 1862306a36Sopenharmony_cistruct gpmc_nand_ops { 1962306a36Sopenharmony_ci bool (*nand_writebuffer_empty)(void); 2062306a36Sopenharmony_ci}; 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_cistruct gpmc_nand_regs; 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_cistruct gpmc_onenand_info { 2562306a36Sopenharmony_ci bool sync_read; 2662306a36Sopenharmony_ci bool sync_write; 2762306a36Sopenharmony_ci int burst_len; 2862306a36Sopenharmony_ci}; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_OMAP_GPMC) 3162306a36Sopenharmony_cistruct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *regs, 3262306a36Sopenharmony_ci int cs); 3362306a36Sopenharmony_ci/** 3462306a36Sopenharmony_ci * gpmc_omap_onenand_set_timings - set optimized sync timings. 3562306a36Sopenharmony_ci * @cs: Chip Select Region 3662306a36Sopenharmony_ci * @freq: Chip frequency 3762306a36Sopenharmony_ci * @latency: Burst latency cycle count 3862306a36Sopenharmony_ci * @info: Structure describing parameters used 3962306a36Sopenharmony_ci * 4062306a36Sopenharmony_ci * Sets optimized timings for the @cs region based on @freq and @latency. 4162306a36Sopenharmony_ci * Updates the @info structure based on the GPMC settings. 4262306a36Sopenharmony_ci */ 4362306a36Sopenharmony_ciint gpmc_omap_onenand_set_timings(struct device *dev, int cs, int freq, 4462306a36Sopenharmony_ci int latency, 4562306a36Sopenharmony_ci struct gpmc_onenand_info *info); 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci#else 4862306a36Sopenharmony_cistatic inline struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *regs, 4962306a36Sopenharmony_ci int cs) 5062306a36Sopenharmony_ci{ 5162306a36Sopenharmony_ci return NULL; 5262306a36Sopenharmony_ci} 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_cistatic inline 5562306a36Sopenharmony_ciint gpmc_omap_onenand_set_timings(struct device *dev, int cs, int freq, 5662306a36Sopenharmony_ci int latency, 5762306a36Sopenharmony_ci struct gpmc_onenand_info *info) 5862306a36Sopenharmony_ci{ 5962306a36Sopenharmony_ci return -EINVAL; 6062306a36Sopenharmony_ci} 6162306a36Sopenharmony_ci#endif /* CONFIG_OMAP_GPMC */ 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ciextern int gpmc_calc_timings(struct gpmc_timings *gpmc_t, 6462306a36Sopenharmony_ci struct gpmc_settings *gpmc_s, 6562306a36Sopenharmony_ci struct gpmc_device_timings *dev_t); 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_cistruct device_node; 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ciextern int gpmc_get_client_irq(unsigned irq_config); 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ciextern unsigned int gpmc_ticks_to_ns(unsigned int ticks); 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ciextern void gpmc_cs_write_reg(int cs, int idx, u32 val); 7462306a36Sopenharmony_ciextern int gpmc_calc_divider(unsigned int sync_clk); 7562306a36Sopenharmony_ciextern int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t, 7662306a36Sopenharmony_ci const struct gpmc_settings *s); 7762306a36Sopenharmony_ciextern int gpmc_cs_program_settings(int cs, struct gpmc_settings *p); 7862306a36Sopenharmony_ciextern int gpmc_cs_request(int cs, unsigned long size, unsigned long *base); 7962306a36Sopenharmony_ciextern void gpmc_cs_free(int cs); 8062306a36Sopenharmony_ciextern int gpmc_configure(int cmd, int wval); 8162306a36Sopenharmony_ciextern void gpmc_read_settings_dt(struct device_node *np, 8262306a36Sopenharmony_ci struct gpmc_settings *p); 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_cistruct gpmc_timings; 8562306a36Sopenharmony_cistruct omap_nand_platform_data; 8662306a36Sopenharmony_cistruct omap_onenand_platform_data; 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_MTD_ONENAND_OMAP2) 8962306a36Sopenharmony_ciextern int gpmc_onenand_init(struct omap_onenand_platform_data *d); 9062306a36Sopenharmony_ci#else 9162306a36Sopenharmony_ci#define board_onenand_data NULL 9262306a36Sopenharmony_cistatic inline int gpmc_onenand_init(struct omap_onenand_platform_data *d) 9362306a36Sopenharmony_ci{ 9462306a36Sopenharmony_ci return 0; 9562306a36Sopenharmony_ci} 9662306a36Sopenharmony_ci#endif 97