Lines Matching refs:cs

267 void gpmc_cs_write_reg(int cs, int idx, u32 val)  in gpmc_cs_write_reg()  argument
271 reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx; in gpmc_cs_write_reg()
275 static u32 gpmc_cs_read_reg(int cs, int idx) in gpmc_cs_read_reg() argument
279 reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx; in gpmc_cs_read_reg()
302 static unsigned long gpmc_get_clk_period(int cs, enum gpmc_clk_domain cd) in gpmc_get_clk_period() argument
311 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); in gpmc_get_clk_period()
324 static unsigned int gpmc_ns_to_clk_ticks(unsigned int time_ns, int cs, in gpmc_ns_to_clk_ticks() argument
330 tick_ps = gpmc_get_clk_period(cs, cd); in gpmc_ns_to_clk_ticks()
350 static unsigned int gpmc_clk_ticks_to_ns(unsigned int ticks, int cs, in gpmc_clk_ticks_to_ns() argument
353 return ticks * gpmc_get_clk_period(cs, cd) / 1000; in gpmc_clk_ticks_to_ns()
373 static inline void gpmc_cs_modify_reg(int cs, int reg, u32 mask, bool value) in gpmc_cs_modify_reg() argument
377 l = gpmc_cs_read_reg(cs, reg); in gpmc_cs_modify_reg()
382 gpmc_cs_write_reg(cs, reg, l); in gpmc_cs_modify_reg()
385 static void gpmc_cs_bool_timings(int cs, const struct gpmc_bool_timings *p) in gpmc_cs_bool_timings() argument
387 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG1, in gpmc_cs_bool_timings()
390 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG2, in gpmc_cs_bool_timings()
392 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG3, in gpmc_cs_bool_timings()
394 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG4, in gpmc_cs_bool_timings()
396 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG4, in gpmc_cs_bool_timings()
398 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG6, in gpmc_cs_bool_timings()
401 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG6, in gpmc_cs_bool_timings()
429 int cs, int reg, int st_bit, int end_bit, int max, in get_gpmc_timing_reg() argument
441 l = gpmc_cs_read_reg(cs, reg); in get_gpmc_timing_reg()
458 time_ns_min = gpmc_clk_ticks_to_ns(l - 1, cs, cd) + 1; in get_gpmc_timing_reg()
459 time_ns = gpmc_clk_ticks_to_ns(l, cs, cd); in get_gpmc_timing_reg()
472 #define GPMC_PRINT_CONFIG(cs, config) \ argument
473 pr_info("cs%i %s: 0x%08x\n", cs, #config, \
474 gpmc_cs_read_reg(cs, config))
476 get_gpmc_timing_reg(cs, (reg), (st), (end), 0, field, GPMC_CD_FCLK, 0, 1, 0)
478 get_gpmc_timing_reg(cs, (reg), (st), (end), (max), field, GPMC_CD_FCLK, 0, 1, 0)
480 get_gpmc_timing_reg(cs, (reg), (st), (end), 0, field, GPMC_CD_FCLK, 0, 1, 1)
482 get_gpmc_timing_reg(cs, (reg), (st), (end), (max), field, GPMC_CD_FCLK, (shift), 1, 1)
484 get_gpmc_timing_reg(cs, (reg), (st), (end), 0, field, GPMC_CD_FCLK, 0, 0, 0)
486 get_gpmc_timing_reg(cs, (reg), (st), (end), 0, field, (cd), 0, 0, 0)
488 get_gpmc_timing_reg(cs, (reg), (st), (end), (max), field, (cd), 0, 0, 0)
490 static void gpmc_show_regs(int cs, const char *desc) in gpmc_show_regs() argument
492 pr_info("gpmc cs%i %s:\n", cs, desc); in gpmc_show_regs()
493 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG1); in gpmc_show_regs()
494 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG2); in gpmc_show_regs()
495 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG3); in gpmc_show_regs()
496 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG4); in gpmc_show_regs()
497 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG5); in gpmc_show_regs()
498 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG6); in gpmc_show_regs()
505 static void gpmc_cs_show_timings(int cs, const char *desc) in gpmc_cs_show_timings() argument
507 gpmc_show_regs(cs, desc); in gpmc_cs_show_timings()
509 pr_info("gpmc cs%i access configuration:\n", cs); in gpmc_cs_show_timings()
536 pr_info("gpmc cs%i timings configuration:\n", cs); in gpmc_cs_show_timings()
581 static inline void gpmc_cs_show_timings(int cs, const char *desc) in gpmc_cs_show_timings() argument
602 static int set_gpmc_timing_reg(int cs, int reg, int st_bit, int end_bit, int max, in set_gpmc_timing_reg() argument
611 ticks = gpmc_ns_to_clk_ticks(time, cs, cd); in set_gpmc_timing_reg()
620 __func__, cs, name, time, ticks, max); in set_gpmc_timing_reg()
625 l = gpmc_cs_read_reg(cs, reg); in set_gpmc_timing_reg()
628 cs, name, ticks, gpmc_get_clk_period(cs, cd) * ticks / 1000, in set_gpmc_timing_reg()
633 gpmc_cs_write_reg(cs, reg, l); in set_gpmc_timing_reg()
693 int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t, in gpmc_cs_set_timings() argument
730 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 0, 3, 0, t->cs_on, in gpmc_cs_set_timings()
732 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 8, 12, 0, t->cs_rd_off, in gpmc_cs_set_timings()
734 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 16, 20, 0, t->cs_wr_off, in gpmc_cs_set_timings()
739 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 0, 3, 0, t->adv_on, in gpmc_cs_set_timings()
741 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 8, 12, 0, t->adv_rd_off, in gpmc_cs_set_timings()
743 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 16, 20, 0, t->adv_wr_off, in gpmc_cs_set_timings()
749 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 4, 6, 0, in gpmc_cs_set_timings()
752 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 24, 26, 0, in gpmc_cs_set_timings()
755 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 28, 30, 0, in gpmc_cs_set_timings()
762 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 0, 3, 0, t->oe_on, in gpmc_cs_set_timings()
764 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 8, 12, 0, t->oe_off, in gpmc_cs_set_timings()
767 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 4, 6, 0, in gpmc_cs_set_timings()
770 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 13, 15, 0, in gpmc_cs_set_timings()
774 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 16, 19, 0, t->we_on, in gpmc_cs_set_timings()
776 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 24, 28, 0, t->we_off, in gpmc_cs_set_timings()
781 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG5, 0, 4, 0, t->rd_cycle, in gpmc_cs_set_timings()
783 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG5, 8, 12, 0, t->wr_cycle, in gpmc_cs_set_timings()
785 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG5, 16, 20, 0, t->access, in gpmc_cs_set_timings()
787 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG5, 24, 27, 0, in gpmc_cs_set_timings()
793 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG6, 0, 3, 0, in gpmc_cs_set_timings()
796 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG6, 8, 11, 0, in gpmc_cs_set_timings()
803 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG6, 16, 19, 0, in gpmc_cs_set_timings()
810 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG6, 24, 28, 0, in gpmc_cs_set_timings()
817 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); in gpmc_cs_set_timings()
820 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, l); in gpmc_cs_set_timings()
823 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG1, 18, 19, in gpmc_cs_set_timings()
827 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG1, 25, 26, in gpmc_cs_set_timings()
836 cs, (div * gpmc_get_fclk_period()) / 1000, div); in gpmc_cs_set_timings()
839 gpmc_cs_bool_timings(cs, &t->bool_timings); in gpmc_cs_set_timings()
840 gpmc_cs_show_timings(cs, "after gpmc_cs_set_timings"); in gpmc_cs_set_timings()
845 static int gpmc_cs_set_memconf(int cs, u32 base, u32 size) in gpmc_cs_set_memconf() argument
862 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_set_memconf()
867 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l); in gpmc_cs_set_memconf()
872 static void gpmc_cs_enable_mem(int cs) in gpmc_cs_enable_mem() argument
876 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_enable_mem()
878 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l); in gpmc_cs_enable_mem()
881 static void gpmc_cs_disable_mem(int cs) in gpmc_cs_disable_mem() argument
885 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_disable_mem()
887 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l); in gpmc_cs_disable_mem()
890 static void gpmc_cs_get_memconf(int cs, u32 *base, u32 *size) in gpmc_cs_get_memconf() argument
895 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_get_memconf()
901 static int gpmc_cs_mem_enabled(int cs) in gpmc_cs_mem_enabled() argument
905 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_mem_enabled()
909 static void gpmc_cs_set_reserved(int cs, int reserved) in gpmc_cs_set_reserved() argument
911 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_set_reserved()
916 static bool gpmc_cs_reserved(int cs) in gpmc_cs_reserved() argument
918 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_reserved()
937 static int gpmc_cs_insert_mem(int cs, unsigned long base, unsigned long size) in gpmc_cs_insert_mem() argument
939 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_insert_mem()
953 static int gpmc_cs_delete_mem(int cs) in gpmc_cs_delete_mem() argument
955 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_delete_mem()
968 int gpmc_cs_request(int cs, unsigned long size, unsigned long *base) in gpmc_cs_request() argument
970 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_request()
974 if (cs >= gpmc_cs_num) { in gpmc_cs_request()
983 if (gpmc_cs_reserved(cs)) { in gpmc_cs_request()
987 if (gpmc_cs_mem_enabled(cs)) in gpmc_cs_request()
996 gpmc_cs_disable_mem(cs); in gpmc_cs_request()
998 r = gpmc_cs_set_memconf(cs, res->start, resource_size(res)); in gpmc_cs_request()
1005 gpmc_cs_enable_mem(cs); in gpmc_cs_request()
1007 gpmc_cs_set_reserved(cs, 1); in gpmc_cs_request()
1014 void gpmc_cs_free(int cs) in gpmc_cs_free() argument
1020 if (cs >= gpmc_cs_num || cs < 0 || !gpmc_cs_reserved(cs)) { in gpmc_cs_free()
1021 WARN(1, "Trying to free non-reserved GPMC CS%d\n", cs); in gpmc_cs_free()
1025 gpmc = &gpmc_cs[cs]; in gpmc_cs_free()
1028 gpmc_cs_disable_mem(cs); in gpmc_cs_free()
1031 gpmc_cs_set_reserved(cs, 0); in gpmc_cs_free()
1085 struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *reg, int cs) in gpmc_omap_get_nand_ops() argument
1089 if (cs >= gpmc_cs_num) in gpmc_omap_get_nand_ops()
1093 GPMC_CS_NAND_COMMAND + GPMC_CS_SIZE * cs; in gpmc_omap_get_nand_ops()
1095 GPMC_CS_NAND_ADDRESS + GPMC_CS_SIZE * cs; in gpmc_omap_get_nand_ops()
1097 GPMC_CS_NAND_DATA + GPMC_CS_SIZE * cs; in gpmc_omap_get_nand_ops()
1207 int gpmc_omap_onenand_set_timings(struct device *dev, int cs, int freq, in gpmc_omap_onenand_set_timings() argument
1226 ret = gpmc_cs_program_settings(cs, &gpmc_s); in gpmc_omap_onenand_set_timings()
1230 return gpmc_cs_set_timings(cs, &gpmc_t, &gpmc_s); in gpmc_omap_onenand_set_timings()
1450 int cs; in gpmc_mem_exit() local
1452 for (cs = 0; cs < gpmc_cs_num; cs++) { in gpmc_mem_exit()
1453 if (!gpmc_cs_mem_enabled(cs)) in gpmc_mem_exit()
1455 gpmc_cs_delete_mem(cs); in gpmc_mem_exit()
1461 int cs; in gpmc_mem_init() local
1467 for (cs = 0; cs < gpmc_cs_num; cs++) { in gpmc_mem_init()
1470 if (!gpmc_cs_mem_enabled(cs)) in gpmc_mem_init()
1472 gpmc_cs_get_memconf(cs, &base, &size); in gpmc_mem_init()
1473 if (gpmc_cs_insert_mem(cs, base, size)) { in gpmc_mem_init()
1475 __func__, cs, base, base + size); in gpmc_mem_init()
1476 gpmc_cs_disable_mem(cs); in gpmc_mem_init()
1813 int gpmc_cs_program_settings(int cs, struct gpmc_settings *p) in gpmc_cs_program_settings() argument
1879 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, config1); in gpmc_cs_program_settings()
1894 static void gpmc_cs_set_name(int cs, const char *name) in gpmc_cs_set_name() argument
1896 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_set_name()
1901 static const char *gpmc_cs_get_name(int cs) in gpmc_cs_get_name() argument
1903 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_get_name()
1917 static int gpmc_cs_remap(int cs, u32 base) in gpmc_cs_remap() argument
1922 if (cs >= gpmc_cs_num) { in gpmc_cs_remap()
1934 gpmc_cs_get_memconf(cs, &old_base, &size); in gpmc_cs_remap()
1938 ret = gpmc_cs_delete_mem(cs); in gpmc_cs_remap()
1942 ret = gpmc_cs_insert_mem(cs, base, size); in gpmc_cs_remap()
1946 ret = gpmc_cs_set_memconf(cs, base, size); in gpmc_cs_remap()
2082 int ret, cs; in gpmc_probe_generic_child() local
2087 if (of_property_read_u32(child, "reg", &cs) < 0) { in gpmc_probe_generic_child()
2104 name = gpmc_cs_get_name(cs); in gpmc_probe_generic_child()
2108 ret = gpmc_cs_request(cs, resource_size(&res), &base); in gpmc_probe_generic_child()
2110 dev_err(&pdev->dev, "cannot request GPMC CS %d\n", cs); in gpmc_probe_generic_child()
2113 gpmc_cs_set_name(cs, child->full_name); in gpmc_probe_generic_child()
2125 cs); in gpmc_probe_generic_child()
2126 gpmc_cs_show_timings(cs, in gpmc_probe_generic_child()
2132 gpmc_cs_disable_mem(cs); in gpmc_probe_generic_child()
2142 ret = gpmc_cs_remap(cs, res.start); in gpmc_probe_generic_child()
2145 cs, &res.start); in gpmc_probe_generic_child()
2149 cs, GPMC_MEM_START); in gpmc_probe_generic_child()
2153 cs, GPMC_MEM_END); in gpmc_probe_generic_child()
2225 gpmc_cs_show_timings(cs, "before gpmc_cs_program_settings"); in gpmc_probe_generic_child()
2227 ret = gpmc_cs_program_settings(cs, &gpmc_s); in gpmc_probe_generic_child()
2231 ret = gpmc_cs_set_timings(cs, &gpmc_t, &gpmc_s); in gpmc_probe_generic_child()
2244 gpmc_cs_enable_mem(cs); in gpmc_probe_generic_child()
2268 gpmc_cs_free(cs); in gpmc_probe_generic_child()