Lines Matching full:ebi
146 * struct stm32_fmc2_prop - STM32 FMC2 EBI property
169 int (*check)(struct stm32_fmc2_ebi *ebi,
171 u32 (*calculate)(struct stm32_fmc2_ebi *ebi, int cs, u32 setup);
172 int (*set)(struct stm32_fmc2_ebi *ebi,
177 static int stm32_fmc2_ebi_check_mux(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_mux() argument
183 regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_mux()
191 static int stm32_fmc2_ebi_check_waitcfg(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_waitcfg() argument
197 regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_waitcfg()
205 static int stm32_fmc2_ebi_check_sync_trans(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_sync_trans() argument
211 regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_sync_trans()
219 static int stm32_fmc2_ebi_check_async_trans(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_async_trans() argument
225 regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_async_trans()
233 static int stm32_fmc2_ebi_check_cpsize(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_cpsize() argument
239 regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_cpsize()
247 static int stm32_fmc2_ebi_check_address_hold(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_address_hold() argument
253 regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_address_hold()
255 regmap_read(ebi->regmap, FMC2_BWTR(cs), &bxtr); in stm32_fmc2_ebi_check_address_hold()
257 regmap_read(ebi->regmap, FMC2_BTR(cs), &bxtr); in stm32_fmc2_ebi_check_address_hold()
266 static int stm32_fmc2_ebi_check_clk_period(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_clk_period() argument
272 regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_clk_period()
274 regmap_read(ebi->regmap, FMC2_BCR1, &bcr1); in stm32_fmc2_ebi_check_clk_period()
284 static int stm32_fmc2_ebi_check_cclk(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_cclk() argument
291 return stm32_fmc2_ebi_check_sync_trans(ebi, prop, cs); in stm32_fmc2_ebi_check_cclk()
294 static u32 stm32_fmc2_ebi_ns_to_clock_cycles(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_ns_to_clock_cycles() argument
297 unsigned long hclk = clk_get_rate(ebi->clk); in stm32_fmc2_ebi_ns_to_clock_cycles()
303 static u32 stm32_fmc2_ebi_ns_to_clk_period(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_ns_to_clk_period() argument
306 u32 nb_clk_cycles = stm32_fmc2_ebi_ns_to_clock_cycles(ebi, cs, setup); in stm32_fmc2_ebi_ns_to_clk_period()
309 regmap_read(ebi->regmap, FMC2_BCR1, &bcr); in stm32_fmc2_ebi_ns_to_clk_period()
311 regmap_read(ebi->regmap, FMC2_BTR1, &btr); in stm32_fmc2_ebi_ns_to_clk_period()
313 regmap_read(ebi->regmap, FMC2_BTR(cs), &btr); in stm32_fmc2_ebi_ns_to_clk_period()
342 static int stm32_fmc2_ebi_set_bit_field(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_bit_field() argument
353 regmap_update_bits(ebi->regmap, reg, prop->reg_mask, in stm32_fmc2_ebi_set_bit_field()
359 static int stm32_fmc2_ebi_set_trans_type(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_trans_type() argument
484 regmap_update_bits(ebi->regmap, FMC2_BWTR(cs), in stm32_fmc2_ebi_set_trans_type()
486 regmap_update_bits(ebi->regmap, FMC2_BTR(cs), btr_mask, btr); in stm32_fmc2_ebi_set_trans_type()
487 regmap_update_bits(ebi->regmap, FMC2_BCR(cs), bcr_mask, bcr); in stm32_fmc2_ebi_set_trans_type()
492 static int stm32_fmc2_ebi_set_buswidth(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_buswidth() argument
510 regmap_update_bits(ebi->regmap, FMC2_BCR(cs), FMC2_BCR_MWID, val); in stm32_fmc2_ebi_set_buswidth()
515 static int stm32_fmc2_ebi_set_cpsize(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_cpsize() argument
542 regmap_update_bits(ebi->regmap, FMC2_BCR(cs), FMC2_BCR_CPSIZE, val); in stm32_fmc2_ebi_set_cpsize()
547 static int stm32_fmc2_ebi_set_bl_setup(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_bl_setup() argument
555 regmap_update_bits(ebi->regmap, FMC2_BCR(cs), FMC2_BCR_NBLSET, val); in stm32_fmc2_ebi_set_bl_setup()
560 static int stm32_fmc2_ebi_set_address_setup(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_address_setup() argument
572 regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_set_address_setup()
574 regmap_read(ebi->regmap, FMC2_BWTR(cs), &bxtr); in stm32_fmc2_ebi_set_address_setup()
576 regmap_read(ebi->regmap, FMC2_BTR(cs), &bxtr); in stm32_fmc2_ebi_set_address_setup()
583 regmap_update_bits(ebi->regmap, reg, FMC2_BXTR_ADDSET, val); in stm32_fmc2_ebi_set_address_setup()
588 static int stm32_fmc2_ebi_set_address_hold(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_address_hold() argument
601 regmap_update_bits(ebi->regmap, reg, FMC2_BXTR_ADDHLD, val); in stm32_fmc2_ebi_set_address_hold()
606 static int stm32_fmc2_ebi_set_data_setup(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_data_setup() argument
619 regmap_update_bits(ebi->regmap, reg, FMC2_BXTR_DATAST, val); in stm32_fmc2_ebi_set_data_setup()
624 static int stm32_fmc2_ebi_set_bus_turnaround(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_bus_turnaround() argument
637 regmap_update_bits(ebi->regmap, reg, FMC2_BXTR_BUSTURN, val); in stm32_fmc2_ebi_set_bus_turnaround()
642 static int stm32_fmc2_ebi_set_data_hold(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_data_hold() argument
658 regmap_update_bits(ebi->regmap, reg, FMC2_BXTR_DATAHLD, val); in stm32_fmc2_ebi_set_data_hold()
663 static int stm32_fmc2_ebi_set_clk_period(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_clk_period() argument
671 regmap_update_bits(ebi->regmap, FMC2_BTR(cs), FMC2_BTR_CLKDIV, val); in stm32_fmc2_ebi_set_clk_period()
676 static int stm32_fmc2_ebi_set_data_latency(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_data_latency() argument
684 regmap_update_bits(ebi->regmap, FMC2_BTR(cs), FMC2_BTR_DATLAT, val); in stm32_fmc2_ebi_set_data_latency()
689 static int stm32_fmc2_ebi_set_max_low_pulse(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_max_low_pulse() argument
698 regmap_read(ebi->regmap, FMC2_PCSCNTR, &pcscntr); in stm32_fmc2_ebi_set_max_low_pulse()
701 regmap_update_bits(ebi->regmap, FMC2_PCSCNTR, in stm32_fmc2_ebi_set_max_low_pulse()
712 regmap_update_bits(ebi->regmap, FMC2_PCSCNTR, in stm32_fmc2_ebi_set_max_low_pulse()
719 /* st,fmc2-ebi-cs-trans-type must be the first property */
721 .name = "st,fmc2-ebi-cs-transaction-type",
726 .name = "st,fmc2-ebi-cs-cclk-enable",
734 .name = "st,fmc2-ebi-cs-mux-enable",
742 .name = "st,fmc2-ebi-cs-buswidth",
747 .name = "st,fmc2-ebi-cs-waitpol-high",
754 .name = "st,fmc2-ebi-cs-waitcfg-enable",
762 .name = "st,fmc2-ebi-cs-wait-enable",
770 .name = "st,fmc2-ebi-cs-asyncwait-enable",
778 .name = "st,fmc2-ebi-cs-cpsize",
783 .name = "st,fmc2-ebi-cs-byte-lane-setup-ns",
788 .name = "st,fmc2-ebi-cs-address-setup-ns",
796 .name = "st,fmc2-ebi-cs-address-hold-ns",
804 .name = "st,fmc2-ebi-cs-data-setup-ns",
812 .name = "st,fmc2-ebi-cs-bus-turnaround-ns",
819 .name = "st,fmc2-ebi-cs-data-hold-ns",
826 .name = "st,fmc2-ebi-cs-clk-period-ns",
833 .name = "st,fmc2-ebi-cs-data-latency-ns",
839 .name = "st,fmc2-ebi-cs-write-address-setup-ns",
847 .name = "st,fmc2-ebi-cs-write-address-hold-ns",
855 .name = "st,fmc2-ebi-cs-write-data-setup-ns",
863 .name = "st,fmc2-ebi-cs-write-bus-turnaround-ns",
870 .name = "st,fmc2-ebi-cs-write-data-hold-ns",
877 .name = "st,fmc2-ebi-cs-max-low-pulse-ns",
883 static int stm32_fmc2_ebi_parse_prop(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_parse_prop() argument
888 struct device *dev = ebi->dev; in stm32_fmc2_ebi_parse_prop()
896 if (prop->check && prop->check(ebi, prop, cs)) in stm32_fmc2_ebi_parse_prop()
926 setup = prop->calculate(ebi, cs, val); in stm32_fmc2_ebi_parse_prop()
931 return prop->set(ebi, prop, cs, setup); in stm32_fmc2_ebi_parse_prop()
934 static void stm32_fmc2_ebi_enable_bank(struct stm32_fmc2_ebi *ebi, int cs) in stm32_fmc2_ebi_enable_bank() argument
936 regmap_update_bits(ebi->regmap, FMC2_BCR(cs), in stm32_fmc2_ebi_enable_bank()
940 static void stm32_fmc2_ebi_disable_bank(struct stm32_fmc2_ebi *ebi, int cs) in stm32_fmc2_ebi_disable_bank() argument
942 regmap_update_bits(ebi->regmap, FMC2_BCR(cs), FMC2_BCR_MBKEN, 0); in stm32_fmc2_ebi_disable_bank()
945 static void stm32_fmc2_ebi_save_setup(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_save_setup() argument
950 regmap_read(ebi->regmap, FMC2_BCR(cs), &ebi->bcr[cs]); in stm32_fmc2_ebi_save_setup()
951 regmap_read(ebi->regmap, FMC2_BTR(cs), &ebi->btr[cs]); in stm32_fmc2_ebi_save_setup()
952 regmap_read(ebi->regmap, FMC2_BWTR(cs), &ebi->bwtr[cs]); in stm32_fmc2_ebi_save_setup()
955 regmap_read(ebi->regmap, FMC2_PCSCNTR, &ebi->pcscntr); in stm32_fmc2_ebi_save_setup()
958 static void stm32_fmc2_ebi_set_setup(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_set_setup() argument
963 regmap_write(ebi->regmap, FMC2_BCR(cs), ebi->bcr[cs]); in stm32_fmc2_ebi_set_setup()
964 regmap_write(ebi->regmap, FMC2_BTR(cs), ebi->btr[cs]); in stm32_fmc2_ebi_set_setup()
965 regmap_write(ebi->regmap, FMC2_BWTR(cs), ebi->bwtr[cs]); in stm32_fmc2_ebi_set_setup()
968 regmap_write(ebi->regmap, FMC2_PCSCNTR, ebi->pcscntr); in stm32_fmc2_ebi_set_setup()
971 static void stm32_fmc2_ebi_disable_banks(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_disable_banks() argument
976 if (!(ebi->bank_assigned & BIT(cs))) in stm32_fmc2_ebi_disable_banks()
979 stm32_fmc2_ebi_disable_bank(ebi, cs); in stm32_fmc2_ebi_disable_banks()
983 /* NWAIT signal can not be connected to EBI controller and NAND controller */
984 static bool stm32_fmc2_ebi_nwait_used_by_ctrls(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_nwait_used_by_ctrls() argument
990 if (!(ebi->bank_assigned & BIT(cs))) in stm32_fmc2_ebi_nwait_used_by_ctrls()
993 regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_nwait_used_by_ctrls()
995 ebi->bank_assigned & BIT(FMC2_NAND)) in stm32_fmc2_ebi_nwait_used_by_ctrls()
1002 static void stm32_fmc2_ebi_enable(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_enable() argument
1004 regmap_update_bits(ebi->regmap, FMC2_BCR1, in stm32_fmc2_ebi_enable()
1008 static void stm32_fmc2_ebi_disable(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_disable() argument
1010 regmap_update_bits(ebi->regmap, FMC2_BCR1, FMC2_BCR1_FMC2EN, 0); in stm32_fmc2_ebi_disable()
1013 static int stm32_fmc2_ebi_setup_cs(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_setup_cs() argument
1020 stm32_fmc2_ebi_disable_bank(ebi, cs); in stm32_fmc2_ebi_setup_cs()
1025 ret = stm32_fmc2_ebi_parse_prop(ebi, dev_node, p, cs); in stm32_fmc2_ebi_setup_cs()
1027 dev_err(ebi->dev, "property %s could not be set: %d\n", in stm32_fmc2_ebi_setup_cs()
1033 stm32_fmc2_ebi_enable_bank(ebi, cs); in stm32_fmc2_ebi_setup_cs()
1038 static int stm32_fmc2_ebi_parse_dt(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_parse_dt() argument
1040 struct device *dev = ebi->dev; in stm32_fmc2_ebi_parse_dt()
1061 if (ebi->bank_assigned & BIT(bank)) { in stm32_fmc2_ebi_parse_dt()
1068 ret = stm32_fmc2_ebi_setup_cs(ebi, child, bank); in stm32_fmc2_ebi_parse_dt()
1077 ebi->bank_assigned |= BIT(bank); in stm32_fmc2_ebi_parse_dt()
1086 if (stm32_fmc2_ebi_nwait_used_by_ctrls(ebi)) { in stm32_fmc2_ebi_parse_dt()
1087 dev_err(dev, "NWAIT signal connected to EBI and NAND controllers\n"); in stm32_fmc2_ebi_parse_dt()
1091 stm32_fmc2_ebi_enable(ebi); in stm32_fmc2_ebi_parse_dt()
1099 struct stm32_fmc2_ebi *ebi; in stm32_fmc2_ebi_probe() local
1103 ebi = devm_kzalloc(&pdev->dev, sizeof(*ebi), GFP_KERNEL); in stm32_fmc2_ebi_probe()
1104 if (!ebi) in stm32_fmc2_ebi_probe()
1107 ebi->dev = dev; in stm32_fmc2_ebi_probe()
1109 ebi->regmap = device_node_to_regmap(dev->of_node); in stm32_fmc2_ebi_probe()
1110 if (IS_ERR(ebi->regmap)) in stm32_fmc2_ebi_probe()
1111 return PTR_ERR(ebi->regmap); in stm32_fmc2_ebi_probe()
1113 ebi->clk = devm_clk_get(dev, NULL); in stm32_fmc2_ebi_probe()
1114 if (IS_ERR(ebi->clk)) in stm32_fmc2_ebi_probe()
1115 return PTR_ERR(ebi->clk); in stm32_fmc2_ebi_probe()
1121 ret = clk_prepare_enable(ebi->clk); in stm32_fmc2_ebi_probe()
1130 ret = stm32_fmc2_ebi_parse_dt(ebi); in stm32_fmc2_ebi_probe()
1134 stm32_fmc2_ebi_save_setup(ebi); in stm32_fmc2_ebi_probe()
1135 platform_set_drvdata(pdev, ebi); in stm32_fmc2_ebi_probe()
1140 stm32_fmc2_ebi_disable_banks(ebi); in stm32_fmc2_ebi_probe()
1141 stm32_fmc2_ebi_disable(ebi); in stm32_fmc2_ebi_probe()
1142 clk_disable_unprepare(ebi->clk); in stm32_fmc2_ebi_probe()
1149 struct stm32_fmc2_ebi *ebi = platform_get_drvdata(pdev); in stm32_fmc2_ebi_remove() local
1152 stm32_fmc2_ebi_disable_banks(ebi); in stm32_fmc2_ebi_remove()
1153 stm32_fmc2_ebi_disable(ebi); in stm32_fmc2_ebi_remove()
1154 clk_disable_unprepare(ebi->clk); in stm32_fmc2_ebi_remove()
1161 struct stm32_fmc2_ebi *ebi = dev_get_drvdata(dev); in stm32_fmc2_ebi_suspend() local
1163 stm32_fmc2_ebi_disable(ebi); in stm32_fmc2_ebi_suspend()
1164 clk_disable_unprepare(ebi->clk); in stm32_fmc2_ebi_suspend()
1172 struct stm32_fmc2_ebi *ebi = dev_get_drvdata(dev); in stm32_fmc2_ebi_resume() local
1177 ret = clk_prepare_enable(ebi->clk); in stm32_fmc2_ebi_resume()
1181 stm32_fmc2_ebi_set_setup(ebi); in stm32_fmc2_ebi_resume()
1182 stm32_fmc2_ebi_enable(ebi); in stm32_fmc2_ebi_resume()
1191 {.compatible = "st,stm32mp1-fmc2-ebi"},
1209 MODULE_DESCRIPTION("STMicroelectronics STM32 FMC2 ebi driver");