Lines Matching refs:cs
263 void gpmc_cs_write_reg(int cs, int idx, u32 val) in gpmc_cs_write_reg() argument
267 reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx; in gpmc_cs_write_reg()
271 static u32 gpmc_cs_read_reg(int cs, int idx) in gpmc_cs_read_reg() argument
275 reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx; in gpmc_cs_read_reg()
298 static unsigned long gpmc_get_clk_period(int cs, enum gpmc_clk_domain cd) in gpmc_get_clk_period() argument
307 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); in gpmc_get_clk_period()
320 static unsigned int gpmc_ns_to_clk_ticks(unsigned int time_ns, int cs, in gpmc_ns_to_clk_ticks() argument
326 tick_ps = gpmc_get_clk_period(cs, cd); in gpmc_ns_to_clk_ticks()
346 static unsigned int gpmc_clk_ticks_to_ns(unsigned int ticks, int cs, in gpmc_clk_ticks_to_ns() argument
349 return ticks * gpmc_get_clk_period(cs, cd) / 1000; in gpmc_clk_ticks_to_ns()
369 static inline void gpmc_cs_modify_reg(int cs, int reg, u32 mask, bool value) in gpmc_cs_modify_reg() argument
373 l = gpmc_cs_read_reg(cs, reg); in gpmc_cs_modify_reg()
378 gpmc_cs_write_reg(cs, reg, l); in gpmc_cs_modify_reg()
381 static void gpmc_cs_bool_timings(int cs, const struct gpmc_bool_timings *p) in gpmc_cs_bool_timings() argument
383 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG1, in gpmc_cs_bool_timings()
386 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG2, in gpmc_cs_bool_timings()
388 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG3, in gpmc_cs_bool_timings()
390 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG4, in gpmc_cs_bool_timings()
392 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG4, in gpmc_cs_bool_timings()
394 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG6, in gpmc_cs_bool_timings()
397 gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG6, in gpmc_cs_bool_timings()
425 int cs, int reg, int st_bit, int end_bit, int max, in get_gpmc_timing_reg() argument
437 l = gpmc_cs_read_reg(cs, reg); in get_gpmc_timing_reg()
454 time_ns_min = gpmc_clk_ticks_to_ns(l - 1, cs, cd) + 1; in get_gpmc_timing_reg()
455 time_ns = gpmc_clk_ticks_to_ns(l, cs, cd); in get_gpmc_timing_reg()
468 #define GPMC_PRINT_CONFIG(cs, config) \ argument
469 pr_info("cs%i %s: 0x%08x\n", cs, #config, \
470 gpmc_cs_read_reg(cs, config))
472 get_gpmc_timing_reg(cs, (reg), (st), (end), 0, field, GPMC_CD_FCLK, 0, 1, 0)
474 get_gpmc_timing_reg(cs, (reg), (st), (end), (max), field, GPMC_CD_FCLK, 0, 1, 0)
476 get_gpmc_timing_reg(cs, (reg), (st), (end), 0, field, GPMC_CD_FCLK, 0, 1, 1)
478 get_gpmc_timing_reg(cs, (reg), (st), (end), (max), field, GPMC_CD_FCLK, (shift), 1, 1)
480 get_gpmc_timing_reg(cs, (reg), (st), (end), 0, field, GPMC_CD_FCLK, 0, 0, 0)
482 get_gpmc_timing_reg(cs, (reg), (st), (end), 0, field, (cd), 0, 0, 0)
484 get_gpmc_timing_reg(cs, (reg), (st), (end), (max), field, (cd), 0, 0, 0)
486 static void gpmc_show_regs(int cs, const char *desc) in gpmc_show_regs() argument
488 pr_info("gpmc cs%i %s:\n", cs, desc); in gpmc_show_regs()
489 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG1); in gpmc_show_regs()
490 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG2); in gpmc_show_regs()
491 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG3); in gpmc_show_regs()
492 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG4); in gpmc_show_regs()
493 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG5); in gpmc_show_regs()
494 GPMC_PRINT_CONFIG(cs, GPMC_CS_CONFIG6); in gpmc_show_regs()
501 static void gpmc_cs_show_timings(int cs, const char *desc) in gpmc_cs_show_timings() argument
503 gpmc_show_regs(cs, desc); in gpmc_cs_show_timings()
505 pr_info("gpmc cs%i access configuration:\n", cs); in gpmc_cs_show_timings()
532 pr_info("gpmc cs%i timings configuration:\n", cs); in gpmc_cs_show_timings()
577 static inline void gpmc_cs_show_timings(int cs, const char *desc) in gpmc_cs_show_timings() argument
598 static int set_gpmc_timing_reg(int cs, int reg, int st_bit, int end_bit, int max, in set_gpmc_timing_reg() argument
607 ticks = gpmc_ns_to_clk_ticks(time, cs, cd); in set_gpmc_timing_reg()
616 __func__, cs, name, time, ticks, max); in set_gpmc_timing_reg()
621 l = gpmc_cs_read_reg(cs, reg); in set_gpmc_timing_reg()
624 cs, name, ticks, gpmc_get_clk_period(cs, cd) * ticks / 1000, in set_gpmc_timing_reg()
629 gpmc_cs_write_reg(cs, reg, l); in set_gpmc_timing_reg()
689 int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t, in gpmc_cs_set_timings() argument
726 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 0, 3, 0, t->cs_on, in gpmc_cs_set_timings()
728 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 8, 12, 0, t->cs_rd_off, in gpmc_cs_set_timings()
730 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 16, 20, 0, t->cs_wr_off, in gpmc_cs_set_timings()
735 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 0, 3, 0, t->adv_on, in gpmc_cs_set_timings()
737 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 8, 12, 0, t->adv_rd_off, in gpmc_cs_set_timings()
739 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 16, 20, 0, t->adv_wr_off, in gpmc_cs_set_timings()
745 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 4, 6, 0, in gpmc_cs_set_timings()
748 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 24, 26, 0, in gpmc_cs_set_timings()
751 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG3, 28, 30, 0, in gpmc_cs_set_timings()
758 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 0, 3, 0, t->oe_on, in gpmc_cs_set_timings()
760 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 8, 12, 0, t->oe_off, in gpmc_cs_set_timings()
763 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 4, 6, 0, in gpmc_cs_set_timings()
766 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 13, 15, 0, in gpmc_cs_set_timings()
770 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 16, 19, 0, t->we_on, in gpmc_cs_set_timings()
772 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG4, 24, 28, 0, t->we_off, in gpmc_cs_set_timings()
777 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG5, 0, 4, 0, t->rd_cycle, in gpmc_cs_set_timings()
779 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG5, 8, 12, 0, t->wr_cycle, in gpmc_cs_set_timings()
781 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG5, 16, 20, 0, t->access, in gpmc_cs_set_timings()
783 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG5, 24, 27, 0, in gpmc_cs_set_timings()
789 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG6, 0, 3, 0, in gpmc_cs_set_timings()
792 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG6, 8, 11, 0, in gpmc_cs_set_timings()
799 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG6, 16, 19, 0, in gpmc_cs_set_timings()
806 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG6, 24, 28, 0, in gpmc_cs_set_timings()
813 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); in gpmc_cs_set_timings()
816 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, l); in gpmc_cs_set_timings()
819 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG1, 18, 19, in gpmc_cs_set_timings()
823 ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG1, 25, 26, in gpmc_cs_set_timings()
832 cs, (div * gpmc_get_fclk_period()) / 1000, div); in gpmc_cs_set_timings()
835 gpmc_cs_bool_timings(cs, &t->bool_timings); in gpmc_cs_set_timings()
836 gpmc_cs_show_timings(cs, "after gpmc_cs_set_timings"); in gpmc_cs_set_timings()
841 static int gpmc_cs_set_memconf(int cs, u32 base, u32 size) in gpmc_cs_set_memconf() argument
858 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_set_memconf()
863 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l); in gpmc_cs_set_memconf()
868 static void gpmc_cs_enable_mem(int cs) in gpmc_cs_enable_mem() argument
872 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_enable_mem()
874 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l); in gpmc_cs_enable_mem()
877 static void gpmc_cs_disable_mem(int cs) in gpmc_cs_disable_mem() argument
881 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_disable_mem()
883 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l); in gpmc_cs_disable_mem()
886 static void gpmc_cs_get_memconf(int cs, u32 *base, u32 *size) in gpmc_cs_get_memconf() argument
891 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_get_memconf()
897 static int gpmc_cs_mem_enabled(int cs) in gpmc_cs_mem_enabled() argument
901 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); in gpmc_cs_mem_enabled()
905 static void gpmc_cs_set_reserved(int cs, int reserved) in gpmc_cs_set_reserved() argument
907 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_set_reserved()
912 static bool gpmc_cs_reserved(int cs) in gpmc_cs_reserved() argument
914 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_reserved()
933 static int gpmc_cs_insert_mem(int cs, unsigned long base, unsigned long size) in gpmc_cs_insert_mem() argument
935 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_insert_mem()
949 static int gpmc_cs_delete_mem(int cs) in gpmc_cs_delete_mem() argument
951 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_delete_mem()
964 int gpmc_cs_request(int cs, unsigned long size, unsigned long *base) in gpmc_cs_request() argument
966 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_request()
970 if (cs >= gpmc_cs_num) { in gpmc_cs_request()
979 if (gpmc_cs_reserved(cs)) { in gpmc_cs_request()
983 if (gpmc_cs_mem_enabled(cs)) in gpmc_cs_request()
992 gpmc_cs_disable_mem(cs); in gpmc_cs_request()
994 r = gpmc_cs_set_memconf(cs, res->start, resource_size(res)); in gpmc_cs_request()
1001 gpmc_cs_enable_mem(cs); in gpmc_cs_request()
1003 gpmc_cs_set_reserved(cs, 1); in gpmc_cs_request()
1010 void gpmc_cs_free(int cs) in gpmc_cs_free() argument
1016 if (cs >= gpmc_cs_num || cs < 0 || !gpmc_cs_reserved(cs)) { in gpmc_cs_free()
1017 WARN(1, "Trying to free non-reserved GPMC CS%d\n", cs); in gpmc_cs_free()
1021 gpmc = &gpmc_cs[cs]; in gpmc_cs_free()
1024 gpmc_cs_disable_mem(cs); in gpmc_cs_free()
1027 gpmc_cs_set_reserved(cs, 0); in gpmc_cs_free()
1081 struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *reg, int cs) in gpmc_omap_get_nand_ops() argument
1085 if (cs >= gpmc_cs_num) in gpmc_omap_get_nand_ops()
1089 GPMC_CS_NAND_COMMAND + GPMC_CS_SIZE * cs; in gpmc_omap_get_nand_ops()
1091 GPMC_CS_NAND_ADDRESS + GPMC_CS_SIZE * cs; in gpmc_omap_get_nand_ops()
1093 GPMC_CS_NAND_DATA + GPMC_CS_SIZE * cs; in gpmc_omap_get_nand_ops()
1203 int gpmc_omap_onenand_set_timings(struct device *dev, int cs, int freq, in gpmc_omap_onenand_set_timings() argument
1222 ret = gpmc_cs_program_settings(cs, &gpmc_s); in gpmc_omap_onenand_set_timings()
1226 return gpmc_cs_set_timings(cs, &gpmc_t, &gpmc_s); in gpmc_omap_onenand_set_timings()
1446 int cs; in gpmc_mem_exit() local
1448 for (cs = 0; cs < gpmc_cs_num; cs++) { in gpmc_mem_exit()
1449 if (!gpmc_cs_mem_enabled(cs)) in gpmc_mem_exit()
1451 gpmc_cs_delete_mem(cs); in gpmc_mem_exit()
1457 int cs; in gpmc_mem_init() local
1463 for (cs = 0; cs < gpmc_cs_num; cs++) { in gpmc_mem_init()
1466 if (!gpmc_cs_mem_enabled(cs)) in gpmc_mem_init()
1468 gpmc_cs_get_memconf(cs, &base, &size); in gpmc_mem_init()
1469 if (gpmc_cs_insert_mem(cs, base, size)) { in gpmc_mem_init()
1471 __func__, cs, base, base + size); in gpmc_mem_init()
1472 gpmc_cs_disable_mem(cs); in gpmc_mem_init()
1809 int gpmc_cs_program_settings(int cs, struct gpmc_settings *p) in gpmc_cs_program_settings() argument
1875 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, config1); in gpmc_cs_program_settings()
1890 static void gpmc_cs_set_name(int cs, const char *name) in gpmc_cs_set_name() argument
1892 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_set_name()
1897 static const char *gpmc_cs_get_name(int cs) in gpmc_cs_get_name() argument
1899 struct gpmc_cs_data *gpmc = &gpmc_cs[cs]; in gpmc_cs_get_name()
1913 static int gpmc_cs_remap(int cs, u32 base) in gpmc_cs_remap() argument
1918 if (cs >= gpmc_cs_num) { in gpmc_cs_remap()
1930 gpmc_cs_get_memconf(cs, &old_base, &size); in gpmc_cs_remap()
1934 ret = gpmc_cs_delete_mem(cs); in gpmc_cs_remap()
1938 ret = gpmc_cs_insert_mem(cs, base, size); in gpmc_cs_remap()
1942 ret = gpmc_cs_set_memconf(cs, base, size); in gpmc_cs_remap()
2078 int ret, cs; in gpmc_probe_generic_child() local
2083 if (of_property_read_u32(child, "reg", &cs) < 0) { in gpmc_probe_generic_child()
2100 name = gpmc_cs_get_name(cs); in gpmc_probe_generic_child()
2104 ret = gpmc_cs_request(cs, resource_size(&res), &base); in gpmc_probe_generic_child()
2106 dev_err(&pdev->dev, "cannot request GPMC CS %d\n", cs); in gpmc_probe_generic_child()
2109 gpmc_cs_set_name(cs, child->full_name); in gpmc_probe_generic_child()
2121 cs); in gpmc_probe_generic_child()
2122 gpmc_cs_show_timings(cs, in gpmc_probe_generic_child()
2128 gpmc_cs_disable_mem(cs); in gpmc_probe_generic_child()
2138 ret = gpmc_cs_remap(cs, res.start); in gpmc_probe_generic_child()
2141 cs, &res.start); in gpmc_probe_generic_child()
2145 cs, GPMC_MEM_START); in gpmc_probe_generic_child()
2149 cs, GPMC_MEM_END); in gpmc_probe_generic_child()
2221 gpmc_cs_show_timings(cs, "before gpmc_cs_program_settings"); in gpmc_probe_generic_child()
2223 ret = gpmc_cs_program_settings(cs, &gpmc_s); in gpmc_probe_generic_child()
2227 ret = gpmc_cs_set_timings(cs, &gpmc_t, &gpmc_s); in gpmc_probe_generic_child()
2240 gpmc_cs_enable_mem(cs); in gpmc_probe_generic_child()
2264 gpmc_cs_free(cs); in gpmc_probe_generic_child()