Lines Matching refs:cs

277 void gpmc_cs_write_reg(int cs, int idx, u32 val)  in gpmc_cs_write_reg()  argument
281 reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx; in gpmc_cs_write_reg()
285 static u32 gpmc_cs_read_reg(int cs, int idx) in gpmc_cs_read_reg() argument
289 reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx; in gpmc_cs_read_reg()
312 static unsigned long gpmc_get_clk_period(int cs, enum gpmc_clk_domain cd) in gpmc_get_clk_period() argument
321 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); in gpmc_get_clk_period()
334 static unsigned int gpmc_ns_to_clk_ticks(unsigned int time_ns, int cs, in gpmc_ns_to_clk_ticks() argument
340 tick_ps = gpmc_get_clk_period(cs, cd); in gpmc_ns_to_clk_ticks()
360 static unsigned int gpmc_clk_ticks_to_ns(unsigned int ticks, int cs, in gpmc_clk_ticks_to_ns() argument
363 return ticks * gpmc_get_clk_period(cs, cd) / 1000; in gpmc_clk_ticks_to_ns()
383 static inline void gpmc_cs_modify_reg(int cs, int reg, u32 mask, bool value) in gpmc_cs_modify_reg() argument
387 l = gpmc_cs_read_reg(cs, reg); in gpmc_cs_modify_reg()
392 gpmc_cs_write_reg(cs, reg, l); in gpmc_cs_modify_reg()
395 static void gpmc_cs_bool_timings(int cs, const struct gpmc_bool_timings *p) in gpmc_cs_bool_timings() argument
397 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG1, in gpmc_cs_bool_timings()
400 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG2, in gpmc_cs_bool_timings()
402 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG3, in gpmc_cs_bool_timings()
404 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG4, in gpmc_cs_bool_timings()
406 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG4, in gpmc_cs_bool_timings()
408 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG6, in gpmc_cs_bool_timings()
411 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG6, in gpmc_cs_bool_timings()
439 int cs, int reg, int st_bit, int end_bit, int max, in get_gpmc_timing_reg() argument
451 l = gpmc_cs_read_reg(cs, reg); in get_gpmc_timing_reg()
468 time_ns_min = gpmc_clk_ticks_to_ns(l - 1, cs, cd) + 1; in get_gpmc_timing_reg()
469 time_ns = gpmc_clk_ticks_to_ns(l, cs, cd); in get_gpmc_timing_reg()
482 #define GPMC_PRINT_CONFIG(cs, config) \ argument
483 pr_info("cs%i %s: 0x%08x\n", cs, #config, \
484 gpmc_cs_read_reg(cs, config))
486 get_gpmc_timing_reg(cs, (reg), (st), (end), 0, field, GPMC_CD_FCLK, 0, 1, 0)
488 get_gpmc_timing_reg(cs, (reg), (st), (end), (max), field, GPMC_CD_FCLK, 0, 1, 0)
490 get_gpmc_timing_reg(cs, (reg), (st), (end), 0, field, GPMC_CD_FCLK, 0, 1, 1)
492 get_gpmc_timing_reg(cs, (reg), (st), (end), (max), field, GPMC_CD_FCLK, (shift), 1, 1)
494 get_gpmc_timing_reg(cs, (reg), (st), (end), 0, field, GPMC_CD_FCLK, 0, 0, 0)
496 get_gpmc_timing_reg(cs, (reg), (st), (end), 0, field, (cd), 0, 0, 0)
498 get_gpmc_timing_reg(cs, (reg), (st), (end), (max), field, (cd), 0, 0, 0)
500 static void gpmc_show_regs(int cs, const char *desc) in gpmc_show_regs() argument
502 pr_info("gpmc cs%i %s:\n", cs, desc); in gpmc_show_regs()
503 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG1); in gpmc_show_regs()
504 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG2); in gpmc_show_regs()
505 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG3); in gpmc_show_regs()
506 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG4); in gpmc_show_regs()
507 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG5); in gpmc_show_regs()
508 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG6); in gpmc_show_regs()
515 static void gpmc_cs_show_timings(int cs, const char *desc) in gpmc_cs_show_timings() argument
517 gpmc_show_regs(cs, desc); in gpmc_cs_show_timings()
519 pr_info("gpmc cs%i access configuration:\n", cs); in gpmc_cs_show_timings()
546 pr_info("gpmc cs%i timings configuration:\n", cs); in gpmc_cs_show_timings()
591 static inline void gpmc_cs_show_timings(int cs, const char *desc) in gpmc_cs_show_timings() argument
612 static int set_gpmc_timing_reg(int cs, int reg, int st_bit, int end_bit, int max, in set_gpmc_timing_reg() argument
621 ticks = gpmc_ns_to_clk_ticks(time, cs, cd); in set_gpmc_timing_reg()
630 __func__, cs, name, time, ticks, max); in set_gpmc_timing_reg()
635 l = gpmc_cs_read_reg(cs, reg); in set_gpmc_timing_reg()
638 cs, name, ticks, gpmc_get_clk_period(cs, cd) * ticks / 1000, in set_gpmc_timing_reg()
643 gpmc_cs_write_reg(cs, reg, l); in set_gpmc_timing_reg()
703 int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t, in gpmc_cs_set_timings() argument
740 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 0, 3, 0, t->cs_on, in gpmc_cs_set_timings()
742 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 8, 12, 0, t->cs_rd_off, in gpmc_cs_set_timings()
744 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 16, 20, 0, t->cs_wr_off, in gpmc_cs_set_timings()
749 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 0, 3, 0, t->adv_on, in gpmc_cs_set_timings()
751 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 8, 12, 0, t->adv_rd_off, in gpmc_cs_set_timings()
753 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 16, 20, 0, t->adv_wr_off, in gpmc_cs_set_timings()
759 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 4, 6, 0, in gpmc_cs_set_timings()
762 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 24, 26, 0, in gpmc_cs_set_timings()
765 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 28, 30, 0, in gpmc_cs_set_timings()
772 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 0, 3, 0, t->oe_on, in gpmc_cs_set_timings()
774 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 8, 12, 0, t->oe_off, in gpmc_cs_set_timings()
777 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 4, 6, 0, in gpmc_cs_set_timings()
780 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 13, 15, 0, in gpmc_cs_set_timings()
784 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 16, 19, 0, t->we_on, in gpmc_cs_set_timings()
786 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 24, 28, 0, t->we_off, in gpmc_cs_set_timings()
791 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG5, 0, 4, 0, t->rd_cycle, in gpmc_cs_set_timings()
793 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG5, 8, 12, 0, t->wr_cycle, in gpmc_cs_set_timings()
795 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG5, 16, 20, 0, t->access, in gpmc_cs_set_timings()
797 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG5, 24, 27, 0, in gpmc_cs_set_timings()
803 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG6, 0, 3, 0, in gpmc_cs_set_timings()
806 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG6, 8, 11, 0, in gpmc_cs_set_timings()
813 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG6, 16, 19, 0, in gpmc_cs_set_timings()
820 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG6, 24, 28, 0, in gpmc_cs_set_timings()
827 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); in gpmc_cs_set_timings()
830 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, l); in gpmc_cs_set_timings()
833 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG1, 18, 19, in gpmc_cs_set_timings()
837 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG1, 25, 26, in gpmc_cs_set_timings()
846 cs, (div * gpmc_get_fclk_period()) / 1000, div); in gpmc_cs_set_timings()
849 gpmc_cs_bool_timings(cs, &t->bool_timings); in gpmc_cs_set_timings()
850 gpmc_cs_show_timings(cs, "after gpmc_cs_set_timings"); in gpmc_cs_set_timings()
855 static int gpmc_cs_set_memconf(int cs, u32 base, u32 size) in gpmc_cs_set_memconf() argument
872 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_set_memconf()
877 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l); in gpmc_cs_set_memconf()
882 static void gpmc_cs_enable_mem(int cs) in gpmc_cs_enable_mem() argument
886 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_enable_mem()
888 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l); in gpmc_cs_enable_mem()
891 static void gpmc_cs_disable_mem(int cs) in gpmc_cs_disable_mem() argument
895 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_disable_mem()
897 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l); in gpmc_cs_disable_mem()
900 static void gpmc_cs_get_memconf(int cs, u32 *base, u32 *size) in gpmc_cs_get_memconf() argument
905 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_get_memconf()
911 static int gpmc_cs_mem_enabled(int cs) in gpmc_cs_mem_enabled() argument
915 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_mem_enabled()
919 static void gpmc_cs_set_reserved(int cs, int reserved) in gpmc_cs_set_reserved() argument
921 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_set_reserved()
926 static bool gpmc_cs_reserved(int cs) in gpmc_cs_reserved() argument
928 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_reserved()
947 static int gpmc_cs_insert_mem(int cs, unsigned long base, unsigned long size) in gpmc_cs_insert_mem() argument
949 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_insert_mem()
963 static int gpmc_cs_delete_mem(int cs) in gpmc_cs_delete_mem() argument
965 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_delete_mem()
978 int gpmc_cs_request(int cs, unsigned long size, unsigned long *base) in gpmc_cs_request() argument
980 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_request()
984 if (cs >= gpmc_cs_num) { in gpmc_cs_request()
993 if (gpmc_cs_reserved(cs)) { in gpmc_cs_request()
997 if (gpmc_cs_mem_enabled(cs)) in gpmc_cs_request()
1006 gpmc_cs_disable_mem(cs); in gpmc_cs_request()
1008 r = gpmc_cs_set_memconf(cs, res->start, resource_size(res)); in gpmc_cs_request()
1015 gpmc_cs_enable_mem(cs); in gpmc_cs_request()
1017 gpmc_cs_set_reserved(cs, 1); in gpmc_cs_request()
1024 void gpmc_cs_free(int cs) in gpmc_cs_free() argument
1030 if (cs >= gpmc_cs_num || cs < 0 || !gpmc_cs_reserved(cs)) { in gpmc_cs_free()
1031 WARN(1, "Trying to free non-reserved GPMC CS%d\n", cs); in gpmc_cs_free()
1035 gpmc = &gpmc_cs[cs]; in gpmc_cs_free()
1038 gpmc_cs_disable_mem(cs); in gpmc_cs_free()
1041 gpmc_cs_set_reserved(cs, 0); in gpmc_cs_free()
1151 struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *reg, int cs) in gpmc_omap_get_nand_ops() argument
1155 if (cs >= gpmc_cs_num) in gpmc_omap_get_nand_ops()
1159 GPMC_CS_NAND_COMMAND + GPMC_CS_SIZE * cs; in gpmc_omap_get_nand_ops()
1161 GPMC_CS_NAND_ADDRESS + GPMC_CS_SIZE * cs; in gpmc_omap_get_nand_ops()
1163 GPMC_CS_NAND_DATA + GPMC_CS_SIZE * cs; in gpmc_omap_get_nand_ops()
1273 int gpmc_omap_onenand_set_timings(struct device *dev, int cs, int freq, in gpmc_omap_onenand_set_timings() argument
1292 ret = gpmc_cs_program_settings(cs, &gpmc_s); in gpmc_omap_onenand_set_timings()
1296 return gpmc_cs_set_timings(cs, &gpmc_t, &gpmc_s); in gpmc_omap_onenand_set_timings()
1516 int cs; in gpmc_mem_exit() local
1518 for (cs = 0; cs < gpmc_cs_num; cs++) { in gpmc_mem_exit()
1519 if (!gpmc_cs_mem_enabled(cs)) in gpmc_mem_exit()
1521 gpmc_cs_delete_mem(cs); in gpmc_mem_exit()
1527 int cs; in gpmc_mem_init() local
1539 for (cs = 0; cs < gpmc_cs_num; cs++) { in gpmc_mem_init()
1542 if (!gpmc_cs_mem_enabled(cs)) in gpmc_mem_init()
1544 gpmc_cs_get_memconf(cs, &base, &size); in gpmc_mem_init()
1545 if (gpmc_cs_insert_mem(cs, base, size)) { in gpmc_mem_init()
1547 __func__, cs, base, base + size); in gpmc_mem_init()
1548 gpmc_cs_disable_mem(cs); in gpmc_mem_init()
1885 int gpmc_cs_program_settings(int cs, struct gpmc_settings *p) in gpmc_cs_program_settings() argument
1952 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, config1); in gpmc_cs_program_settings()
1969 static void gpmc_cs_set_name(int cs, const char *name) in gpmc_cs_set_name() argument
1971 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_set_name()
1976 static const char *gpmc_cs_get_name(int cs) in gpmc_cs_get_name() argument
1978 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_get_name()
1992 static int gpmc_cs_remap(int cs, u32 base) in gpmc_cs_remap() argument
1997 if (cs >= gpmc_cs_num) { in gpmc_cs_remap()
2009 gpmc_cs_get_memconf(cs, &old_base, &size); in gpmc_cs_remap()
2013 ret = gpmc_cs_delete_mem(cs); in gpmc_cs_remap()
2017 ret = gpmc_cs_insert_mem(cs, base, size); in gpmc_cs_remap()
2021 ret = gpmc_cs_set_memconf(cs, base, size); in gpmc_cs_remap()
2175 int ret, cs; in gpmc_probe_generic_child() local
2179 if (of_property_read_u32(child, "reg", &cs) < 0) { in gpmc_probe_generic_child()
2196 name = gpmc_cs_get_name(cs); in gpmc_probe_generic_child()
2200 ret = gpmc_cs_request(cs, resource_size(&res), &base); in gpmc_probe_generic_child()
2202 dev_err(&pdev->dev, "cannot request GPMC CS %d\n", cs); in gpmc_probe_generic_child()
2205 gpmc_cs_set_name(cs, child->full_name); in gpmc_probe_generic_child()
2217 cs); in gpmc_probe_generic_child()
2218 gpmc_cs_show_timings(cs, in gpmc_probe_generic_child()
2224 gpmc_cs_disable_mem(cs); in gpmc_probe_generic_child()
2234 ret = gpmc_cs_remap(cs, res.start); in gpmc_probe_generic_child()
2237 cs, &res.start); in gpmc_probe_generic_child()
2241 cs, GPMC_MEM_START); in gpmc_probe_generic_child()
2245 cs, GPMC_MEM_END); in gpmc_probe_generic_child()
2309 gpmc_cs_show_timings(cs, "before gpmc_cs_program_settings"); in gpmc_probe_generic_child()
2311 ret = gpmc_cs_program_settings(cs, &gpmc_s); in gpmc_probe_generic_child()
2315 ret = gpmc_cs_set_timings(cs, &gpmc_t, &gpmc_s); in gpmc_probe_generic_child()
2328 gpmc_cs_enable_mem(cs); in gpmc_probe_generic_child()
2350 gpmc_cs_free(cs); in gpmc_probe_generic_child()