Lines Matching refs:otpc
57 static struct mchp_otpc_packet *mchp_otpc_id_to_packet(struct mchp_otpc *otpc, in mchp_otpc_id_to_packet() argument
62 if (id >= otpc->npackets) in mchp_otpc_id_to_packet()
65 list_for_each_entry(packet, &otpc->packets, list) { in mchp_otpc_id_to_packet()
73 static int mchp_otpc_prepare_read(struct mchp_otpc *otpc, in mchp_otpc_prepare_read() argument
79 tmp = readl_relaxed(otpc->base + MCHP_OTPC_MR); in mchp_otpc_prepare_read()
82 writel_relaxed(tmp, otpc->base + MCHP_OTPC_MR); in mchp_otpc_prepare_read()
85 tmp = readl_relaxed(otpc->base + MCHP_OTPC_CR); in mchp_otpc_prepare_read()
87 writel_relaxed(tmp, otpc->base + MCHP_OTPC_CR); in mchp_otpc_prepare_read()
91 10000, 2000, false, otpc->base + MCHP_OTPC_SR); in mchp_otpc_prepare_read()
149 struct mchp_otpc *otpc = priv; in mchp_otpc_read() local
162 packet = mchp_otpc_id_to_packet(otpc, off / 4); in mchp_otpc_read()
168 ret = mchp_otpc_prepare_read(otpc, offset); in mchp_otpc_read()
173 *buf++ = readl_relaxed(otpc->base + MCHP_OTPC_HR); in mchp_otpc_read()
181 writel_relaxed(0UL, otpc->base + MCHP_OTPC_AR); in mchp_otpc_read()
183 *buf++ = readl_relaxed(otpc->base + MCHP_OTPC_DR); in mchp_otpc_read()
193 static int mchp_otpc_init_packets_list(struct mchp_otpc *otpc, u32 *size) in mchp_otpc_init_packets_list() argument
199 INIT_LIST_HEAD(&otpc->packets); in mchp_otpc_init_packets_list()
203 ret = mchp_otpc_prepare_read(otpc, word_pos); in mchp_otpc_init_packets_list()
207 word = readl_relaxed(otpc->base + MCHP_OTPC_HR); in mchp_otpc_init_packets_list()
212 packet = devm_kzalloc(otpc->dev, sizeof(*packet), GFP_KERNEL); in mchp_otpc_init_packets_list()
219 list_add_tail(&packet->list, &otpc->packets); in mchp_otpc_init_packets_list()
229 otpc->npackets = npackets; in mchp_otpc_init_packets_list()
246 struct mchp_otpc *otpc; in mchp_otpc_probe() local
250 otpc = devm_kzalloc(&pdev->dev, sizeof(*otpc), GFP_KERNEL); in mchp_otpc_probe()
251 if (!otpc) in mchp_otpc_probe()
254 otpc->base = devm_platform_ioremap_resource(pdev, 0); in mchp_otpc_probe()
255 if (IS_ERR(otpc->base)) in mchp_otpc_probe()
256 return PTR_ERR(otpc->base); in mchp_otpc_probe()
258 otpc->dev = &pdev->dev; in mchp_otpc_probe()
259 ret = mchp_otpc_init_packets_list(otpc, &size); in mchp_otpc_probe()
263 mchp_nvmem_config.dev = otpc->dev; in mchp_otpc_probe()
266 mchp_nvmem_config.priv = otpc; in mchp_otpc_probe()