blob: 053feb41510ab3b9765be4eac517f84248896606 [file] [log] [blame]
Tony Lindgrene639cd52014-11-20 12:11:25 -08001/*
2 * OMAP GPMC (General Purpose Memory Controller) defines
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
Roger Quadros58bc67f2015-07-10 15:23:28 +030010#include <linux/platform_data/gpmc-omap.h>
Tony Lindgrene639cd52014-11-20 12:11:25 -080011
12#define GPMC_CONFIG_WP 0x00000005
13
Roger Quadros384258f2015-07-30 14:49:23 +030014/* IRQ numbers in GPMC IRQ domain for legacy boot use */
15#define GPMC_IRQ_FIFOEVENTENABLE 0
16#define GPMC_IRQ_COUNT_EVENT 1
Tony Lindgrene639cd52014-11-20 12:11:25 -080017
Roger Quadrosf47fcad2015-08-05 13:58:01 +030018/**
19 * gpmc_nand_ops - Interface between NAND and GPMC
20 * @nand_write_buffer_empty: get the NAND write buffer empty status.
21 */
22struct gpmc_nand_ops {
23 bool (*nand_writebuffer_empty)(void);
24};
25
26struct gpmc_nand_regs;
27
Ladislav Michla758f502018-01-12 14:17:25 +010028struct gpmc_onenand_info {
29 bool sync_read;
30 bool sync_write;
31 int burst_len;
32};
33
Roger Quadrosf47fcad2015-08-05 13:58:01 +030034#if IS_ENABLED(CONFIG_OMAP_GPMC)
35struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *regs,
36 int cs);
Ladislav Michla758f502018-01-12 14:17:25 +010037/**
38 * gpmc_omap_onenand_set_timings - set optimized sync timings.
39 * @cs: Chip Select Region
40 * @freq: Chip frequency
41 * @latency: Burst latency cycle count
42 * @info: Structure describing parameters used
43 *
44 * Sets optimized timings for the @cs region based on @freq and @latency.
45 * Updates the @info structure based on the GPMC settings.
46 */
47int gpmc_omap_onenand_set_timings(struct device *dev, int cs, int freq,
48 int latency,
49 struct gpmc_onenand_info *info);
50
Roger Quadrosf47fcad2015-08-05 13:58:01 +030051#else
Roger Quadros0680b0c2016-08-24 12:10:17 +030052static inline struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *regs,
53 int cs)
Roger Quadrosf47fcad2015-08-05 13:58:01 +030054{
55 return NULL;
56}
Ladislav Michla758f502018-01-12 14:17:25 +010057
58static inline
59int gpmc_omap_onenand_set_timings(struct device *dev, int cs, int freq,
60 int latency,
61 struct gpmc_onenand_info *info)
62{
63 return -EINVAL;
64}
Roger Quadrosf47fcad2015-08-05 13:58:01 +030065#endif /* CONFIG_OMAP_GPMC */
66
Tony Lindgrene639cd52014-11-20 12:11:25 -080067extern int gpmc_calc_timings(struct gpmc_timings *gpmc_t,
68 struct gpmc_settings *gpmc_s,
69 struct gpmc_device_timings *dev_t);
70
Tony Lindgrene639cd52014-11-20 12:11:25 -080071struct device_node;
72
Tony Lindgrene639cd52014-11-20 12:11:25 -080073extern int gpmc_get_client_irq(unsigned irq_config);
74
75extern unsigned int gpmc_ticks_to_ns(unsigned int ticks);
76
77extern void gpmc_cs_write_reg(int cs, int idx, u32 val);
78extern int gpmc_calc_divider(unsigned int sync_clk);
Robert ABEL2e676902015-02-27 16:56:53 +010079extern int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t,
80 const struct gpmc_settings *s);
Tony Lindgrene639cd52014-11-20 12:11:25 -080081extern int gpmc_cs_program_settings(int cs, struct gpmc_settings *p);
82extern int gpmc_cs_request(int cs, unsigned long size, unsigned long *base);
83extern void gpmc_cs_free(int cs);
84extern int gpmc_configure(int cmd, int wval);
85extern void gpmc_read_settings_dt(struct device_node *np,
86 struct gpmc_settings *p);
87
88extern void omap3_gpmc_save_context(void);
89extern void omap3_gpmc_restore_context(void);
90
91struct gpmc_timings;
92struct omap_nand_platform_data;
93struct omap_onenand_platform_data;
94
Tony Lindgrene639cd52014-11-20 12:11:25 -080095#if IS_ENABLED(CONFIG_MTD_ONENAND_OMAP2)
Ladislav Michl7807e082017-02-11 14:02:49 +010096extern int gpmc_onenand_init(struct omap_onenand_platform_data *d);
Tony Lindgrene639cd52014-11-20 12:11:25 -080097#else
98#define board_onenand_data NULL
Ladislav Michl7807e082017-02-11 14:02:49 +010099static inline int gpmc_onenand_init(struct omap_onenand_platform_data *d)
Tony Lindgrene639cd52014-11-20 12:11:25 -0800100{
Ladislav Michl7807e082017-02-11 14:02:49 +0100101 return 0;
Tony Lindgrene639cd52014-11-20 12:11:25 -0800102}
103#endif