Skip to content

Commit f47fcad

Browse files
author
Roger Quadros
committed
memory: omap-gpmc: Introduce GPMC to NAND interface
The OMAP GPMC module has certain registers dedicated for NAND access and some NAND bits mixed with other GPMC functionality. For the NAND dedicated registers we have the struct gpmc_nand_regs. The NAND driver needs to access NAND specific bits from the following non-dedicated registers - EMPTYWRITEBUFFERSTATUS from GPMC_STATUS For accessing these bits we introduce the struct gpmc_nand_ops. Add gpmc_omap_get_nand_ops() that returns the gpmc_nand_ops along with updating the gpmc_nand_regs. This API will be called by the OMAP NAND driver to access the necessary bits in GPMC register space. Signed-off-by: Roger Quadros <[email protected]> Acked-by: Tony Lindgren <[email protected]>
1 parent fabe7d7 commit f47fcad

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

drivers/memory/omap-gpmc.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,27 @@ void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs)
11181118
}
11191119
}
11201120

1121+
static struct gpmc_nand_ops nand_ops;
1122+
1123+
/**
1124+
* gpmc_omap_get_nand_ops - Get the GPMC NAND interface
1125+
* @regs: the GPMC NAND register map exclusive for NAND use.
1126+
* @cs: GPMC chip select number on which the NAND sits. The
1127+
* register map returned will be specific to this chip select.
1128+
*
1129+
* Returns NULL on error e.g. invalid cs.
1130+
*/
1131+
struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *reg, int cs)
1132+
{
1133+
if (cs >= gpmc_cs_num)
1134+
return NULL;
1135+
1136+
gpmc_update_nand_reg(reg, cs);
1137+
1138+
return &nand_ops;
1139+
}
1140+
EXPORT_SYMBOL_GPL(gpmc_omap_get_nand_ops);
1141+
11211142
int gpmc_get_client_irq(unsigned irq_config)
11221143
{
11231144
int i;

include/linux/omap-gpmc.h

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,45 @@
1414
#define GPMC_IRQ_FIFOEVENTENABLE 0x01
1515
#define GPMC_IRQ_COUNT_EVENT 0x02
1616

17+
/**
18+
* gpmc_nand_ops - Interface between NAND and GPMC
19+
* @nand_write_buffer_empty: get the NAND write buffer empty status.
20+
*/
21+
struct gpmc_nand_ops {
22+
bool (*nand_writebuffer_empty)(void);
23+
};
24+
25+
struct gpmc_nand_regs;
26+
27+
#if IS_ENABLED(CONFIG_OMAP_GPMC)
28+
struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *regs,
29+
int cs);
30+
#else
31+
static inline gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *regs,
32+
int cs)
33+
{
34+
return NULL;
35+
}
36+
#endif /* CONFIG_OMAP_GPMC */
37+
38+
/*--------------------------------*/
39+
40+
/* deprecated APIs */
41+
#if IS_ENABLED(CONFIG_OMAP_GPMC)
42+
void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs);
43+
#else
44+
static inline void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs)
45+
{
46+
}
47+
#endif /* CONFIG_OMAP_GPMC */
48+
/*--------------------------------*/
49+
1750
extern int gpmc_calc_timings(struct gpmc_timings *gpmc_t,
1851
struct gpmc_settings *gpmc_s,
1952
struct gpmc_device_timings *dev_t);
2053

21-
struct gpmc_nand_regs;
2254
struct device_node;
2355

24-
extern void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs);
2556
extern int gpmc_get_client_irq(unsigned irq_config);
2657

2758
extern unsigned int gpmc_ticks_to_ns(unsigned int ticks);

0 commit comments

Comments
 (0)