Lines Matching refs:vc7
124 struct vc7_driver_data *vc7; member
133 struct vc7_driver_data *vc7; member
142 struct vc7_driver_data *vc7; member
149 struct vc7_driver_data *vc7; member
180 struct vc7_driver_data *vc7 = data; in vc7_of_clk_get() local
183 if (idx >= vc7->chip_info->num_outputs) in vc7_of_clk_get()
186 return &vc7->clk_out[idx].hw; in vc7_of_clk_get()
369 static int vc7_get_bank_clk(struct vc7_driver_data *vc7, in vc7_get_bank_clk() argument
379 map->src.iod = &vc7->clk_iod[0]; in vc7_get_bank_clk()
383 map->src.iod = &vc7->clk_iod[1]; in vc7_get_bank_clk()
387 map->src.fod = &vc7->clk_fod[0]; in vc7_get_bank_clk()
391 map->src.fod = &vc7->clk_fod[1]; in vc7_get_bank_clk()
400 map->src.iod = &vc7->clk_iod[1]; in vc7_get_bank_clk()
404 map->src.fod = &vc7->clk_fod[0]; in vc7_get_bank_clk()
408 map->src.fod = &vc7->clk_fod[1]; in vc7_get_bank_clk()
417 map->src.fod = &vc7->clk_fod[0]; in vc7_get_bank_clk()
421 map->src.fod = &vc7->clk_fod[1]; in vc7_get_bank_clk()
425 map->src.fod = &vc7->clk_fod[2]; in vc7_get_bank_clk()
437 map->src.iod = &vc7->clk_iod[2]; in vc7_get_bank_clk()
441 map->src.fod = &vc7->clk_fod[1]; in vc7_get_bank_clk()
445 map->src.fod = &vc7->clk_fod[2]; in vc7_get_bank_clk()
463 map->src.iod = &vc7->clk_iod[2]; in vc7_get_bank_clk()
467 map->src.iod = &vc7->clk_iod[3]; in vc7_get_bank_clk()
471 map->src.fod = &vc7->clk_fod[1]; in vc7_get_bank_clk()
475 map->src.fod = &vc7->clk_fod[2]; in vc7_get_bank_clk()
490 map->src.iod = &vc7->clk_iod[2]; in vc7_get_bank_clk()
494 map->src.iod = &vc7->clk_iod[3]; in vc7_get_bank_clk()
498 map->src.fod = &vc7->clk_fod[1]; in vc7_get_bank_clk()
502 map->src.fod = &vc7->clk_fod[2]; in vc7_get_bank_clk()
516 static int vc7_read_apll(struct vc7_driver_data *vc7) in vc7_read_apll() argument
522 err = regmap_bulk_read(vc7->regmap, in vc7_read_apll()
527 dev_err(&vc7->client->dev, "failed to read XO_CNFG\n"); in vc7_read_apll()
531 vc7->clk_apll.xo_ib_h_div = (val32 & VC7_REG_XO_IB_H_DIV_MASK) in vc7_read_apll()
534 err = regmap_read(vc7->regmap, in vc7_read_apll()
538 dev_err(&vc7->client->dev, "failed to read APLL_CNFG\n"); in vc7_read_apll()
542 vc7->clk_apll.en_doubler = val32 & VC7_REG_APLL_EN_DOUBLER; in vc7_read_apll()
544 err = regmap_bulk_read(vc7->regmap, in vc7_read_apll()
549 dev_err(&vc7->client->dev, "failed to read APLL_FB_DIV_FRAC\n"); in vc7_read_apll()
553 vc7->clk_apll.apll_fb_div_frac = val32 & VC7_REG_APLL_FB_DIV_FRAC_MASK; in vc7_read_apll()
555 err = regmap_bulk_read(vc7->regmap, in vc7_read_apll()
560 dev_err(&vc7->client->dev, "failed to read APLL_FB_DIV_INT\n"); in vc7_read_apll()
564 vc7->clk_apll.apll_fb_div_int = val16 & VC7_REG_APLL_FB_DIV_INT_MASK; in vc7_read_apll()
569 static int vc7_read_fod(struct vc7_driver_data *vc7, unsigned int idx) in vc7_read_fod() argument
574 err = regmap_bulk_read(vc7->regmap, in vc7_read_fod()
579 dev_err(&vc7->client->dev, "failed to read FOD%d\n", idx); in vc7_read_fod()
583 vc7->clk_fod[idx].fod_1st_int = (val & VC7_REG_FOD_1ST_INT_MASK); in vc7_read_fod()
584 vc7->clk_fod[idx].fod_2nd_int = in vc7_read_fod()
586 vc7->clk_fod[idx].fod_frac = (val & VC7_REG_FOD_FRAC_MASK) in vc7_read_fod()
592 static int vc7_write_fod(struct vc7_driver_data *vc7, unsigned int idx) in vc7_write_fod() argument
603 err = regmap_bulk_read(vc7->regmap, in vc7_write_fod()
608 dev_err(&vc7->client->dev, "failed to read FOD%d\n", idx); in vc7_write_fod()
613 vc7->clk_fod[idx].fod_1st_int, in vc7_write_fod()
616 vc7->clk_fod[idx].fod_2nd_int, in vc7_write_fod()
619 vc7->clk_fod[idx].fod_frac, in vc7_write_fod()
622 err = regmap_bulk_write(vc7->regmap, in vc7_write_fod()
627 dev_err(&vc7->client->dev, "failed to write FOD%d\n", idx); in vc7_write_fod()
634 static int vc7_read_iod(struct vc7_driver_data *vc7, unsigned int idx) in vc7_read_iod() argument
639 err = regmap_bulk_read(vc7->regmap, in vc7_read_iod()
644 dev_err(&vc7->client->dev, "failed to read IOD%d\n", idx); in vc7_read_iod()
648 vc7->clk_iod[idx].iod_int = (val & VC7_REG_IOD_INT_MASK); in vc7_read_iod()
653 static int vc7_write_iod(struct vc7_driver_data *vc7, unsigned int idx) in vc7_write_iod() argument
663 err = regmap_bulk_read(vc7->regmap, in vc7_write_iod()
668 dev_err(&vc7->client->dev, "failed to read IOD%d\n", idx); in vc7_write_iod()
673 vc7->clk_iod[idx].iod_int, in vc7_write_iod()
676 err = regmap_bulk_write(vc7->regmap, in vc7_write_iod()
681 dev_err(&vc7->client->dev, "failed to write IOD%d\n", idx); in vc7_write_iod()
688 static int vc7_read_output(struct vc7_driver_data *vc7, unsigned int idx) in vc7_read_output() argument
693 out_num = vc7_map_index_to_output(vc7->chip_info->model, idx); in vc7_read_output()
694 err = regmap_read(vc7->regmap, in vc7_read_output()
698 dev_err(&vc7->client->dev, "failed to read ODRV_EN[%d]\n", idx); in vc7_read_output()
702 vc7->clk_out[idx].out_dis = val & VC7_REG_OUT_DIS; in vc7_read_output()
707 static int vc7_write_output(struct vc7_driver_data *vc7, unsigned int idx) in vc7_write_output() argument
712 out_num = vc7_map_index_to_output(vc7->chip_info->model, idx); in vc7_write_output()
713 err = regmap_write_bits(vc7->regmap, in vc7_write_output()
716 vc7->clk_out[idx].out_dis); in vc7_write_output()
719 dev_err(&vc7->client->dev, "failed to write ODRV_EN[%d]\n", idx); in vc7_write_output()
726 static unsigned long vc7_get_apll_rate(struct vc7_driver_data *vc7) in vc7_get_apll_rate() argument
732 xtal_rate = clk_get_rate(vc7->pin_xin); in vc7_get_apll_rate()
733 err = vc7_read_apll(vc7); in vc7_get_apll_rate()
735 dev_err(&vc7->client->dev, "unable to read apll\n"); in vc7_get_apll_rate()
740 if (vc7->clk_apll.xo_ib_h_div < 2) in vc7_get_apll_rate()
743 refin_div = div64_u64(xtal_rate, vc7->clk_apll.xo_ib_h_div); in vc7_get_apll_rate()
745 if (vc7->clk_apll.en_doubler) in vc7_get_apll_rate()
749 apll_rate = (refin_div * vc7->clk_apll.apll_fb_div_int) + in vc7_get_apll_rate()
750 ((refin_div * vc7->clk_apll.apll_fb_div_frac) >> VC7_APLL_DENOMINATOR_BITS); in vc7_get_apll_rate()
753 __func__, vc7->clk_apll.xo_ib_h_div, vc7->clk_apll.apll_fb_div_int, in vc7_get_apll_rate()
754 vc7->clk_apll.apll_fb_div_frac); in vc7_get_apll_rate()
879 struct vc7_driver_data *vc7 = fod->vc7; in vc7_fod_recalc_rate() local
883 err = vc7_read_fod(vc7, fod->num); in vc7_fod_recalc_rate()
885 dev_err(&vc7->client->dev, "error reading registers for %s\n", in vc7_fod_recalc_rate()
927 struct vc7_driver_data *vc7 = fod->vc7; in vc7_fod_set_rate() local
934 dev_err(&vc7->client->dev, in vc7_fod_set_rate()
940 vc7_write_fod(vc7, fod->num); in vc7_fod_set_rate()
962 struct vc7_driver_data *vc7 = iod->vc7; in vc7_iod_recalc_rate() local
966 err = vc7_read_iod(vc7, iod->num); in vc7_iod_recalc_rate()
968 dev_err(&vc7->client->dev, "error reading registers for %s\n", in vc7_iod_recalc_rate()
1001 struct vc7_driver_data *vc7 = iod->vc7; in vc7_iod_set_rate() local
1008 dev_err(&vc7->client->dev, in vc7_iod_set_rate()
1014 vc7_write_iod(vc7, iod->num); in vc7_iod_set_rate()
1033 struct vc7_driver_data *vc7 = out->vc7; in vc7_clk_out_prepare() local
1038 err = vc7_write_output(vc7, out->num); in vc7_clk_out_prepare()
1040 dev_err(&vc7->client->dev, "error writing registers for %s\n", in vc7_clk_out_prepare()
1053 struct vc7_driver_data *vc7 = out->vc7; in vc7_clk_out_unprepare() local
1058 err = vc7_write_output(vc7, out->num); in vc7_clk_out_unprepare()
1060 dev_err(&vc7->client->dev, "error writing registers for %s\n", in vc7_clk_out_unprepare()
1071 struct vc7_driver_data *vc7 = out->vc7; in vc7_clk_out_is_enabled() local
1074 err = vc7_read_output(vc7, out->num); in vc7_clk_out_is_enabled()
1076 dev_err(&vc7->client->dev, "error reading registers for %s\n", in vc7_clk_out_is_enabled()
1096 struct vc7_driver_data *vc7; in vc7_probe() local
1105 vc7 = devm_kzalloc(&client->dev, sizeof(*vc7), GFP_KERNEL); in vc7_probe()
1106 if (!vc7) in vc7_probe()
1109 i2c_set_clientdata(client, vc7); in vc7_probe()
1110 vc7->client = client; in vc7_probe()
1111 vc7->chip_info = i2c_get_match_data(client); in vc7_probe()
1113 vc7->pin_xin = devm_clk_get(&client->dev, "xin"); in vc7_probe()
1114 if (PTR_ERR(vc7->pin_xin) == -EPROBE_DEFER) { in vc7_probe()
1119 vc7->regmap = devm_regmap_init_i2c(client, &vc7_regmap_config); in vc7_probe()
1120 if (IS_ERR(vc7->regmap)) { in vc7_probe()
1121 return dev_err_probe(&client->dev, PTR_ERR(vc7->regmap), in vc7_probe()
1130 apll_rate = vc7_get_apll_rate(vc7); in vc7_probe()
1132 vc7->clk_apll.clk = clk_register_fixed_rate(&client->dev, apll_name, in vc7_probe()
1133 __clk_get_name(vc7->pin_xin), in vc7_probe()
1136 if (IS_ERR(vc7->clk_apll.clk)) { in vc7_probe()
1137 return dev_err_probe(&client->dev, PTR_ERR(vc7->clk_apll.clk), in vc7_probe()
1147 parent_names[0] = __clk_get_name(vc7->clk_apll.clk); in vc7_probe()
1149 vc7->clk_fod[i].num = i; in vc7_probe()
1150 vc7->clk_fod[i].vc7 = vc7; in vc7_probe()
1151 vc7->clk_fod[i].hw.init = &clk_init; in vc7_probe()
1152 ret = devm_clk_hw_register(&client->dev, &vc7->clk_fod[i].hw); in vc7_probe()
1164 parent_names[0] = __clk_get_name(vc7->clk_apll.clk); in vc7_probe()
1166 vc7->clk_iod[i].num = i; in vc7_probe()
1167 vc7->clk_iod[i].vc7 = vc7; in vc7_probe()
1168 vc7->clk_iod[i].hw.init = &clk_init; in vc7_probe()
1169 ret = devm_clk_hw_register(&client->dev, &vc7->clk_iod[i].hw); in vc7_probe()
1176 for (i = 0; i < vc7->chip_info->num_outputs; i++) { in vc7_probe()
1177 out_num = vc7_map_index_to_output(vc7->chip_info->model, i); in vc7_probe()
1186 regmap_read(vc7->regmap, VC7_REG_OUT_BANK_CNFG(bank_idx), &val); in vc7_probe()
1190 ret = vc7_get_bank_clk(vc7, bank_idx, val, &bank_src_map); in vc7_probe()
1212 vc7->clk_out[i].num = i; in vc7_probe()
1213 vc7->clk_out[i].vc7 = vc7; in vc7_probe()
1214 vc7->clk_out[i].hw.init = &clk_init; in vc7_probe()
1215 ret = devm_clk_hw_register(&client->dev, &vc7->clk_out[i].hw); in vc7_probe()
1221 ret = of_clk_add_hw_provider(client->dev.of_node, vc7_of_clk_get, vc7); in vc7_probe()
1234 clk_unregister_fixed_rate(vc7->clk_apll.clk); in vc7_probe()
1240 struct vc7_driver_data *vc7 = i2c_get_clientdata(client); in vc7_remove() local
1243 clk_unregister_fixed_rate(vc7->clk_apll.clk); in vc7_remove()