Skip to content

Commit d83e561

Browse files
sean-anderson-secobebarino
authored andcommitted
clk: vc5: Add properties for configuring SD/OE behavior
The SD/OE pin may be configured to enable output when high or low, and to shutdown the device when high. This behavior is controller by the SH and SP bits of the Primary Source and Shutdown Register (and to a lesser extent the OS and OE bits). By default, both bits are 0 (unless set by OTP memory), but they may need to be configured differently, depending on the external circuitry controlling the SD/OE pin. Signed-off-by: Sean Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 2ef1625 commit d83e561

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/clk/clk-versaclock5.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ static const struct of_device_id clk_vc5_of_match[];
907907

908908
static int vc5_probe(struct i2c_client *client, const struct i2c_device_id *id)
909909
{
910+
unsigned int oe, sd, src_mask = 0, src_val = 0;
910911
struct vc5_driver_data *vc5;
911912
struct clk_init_data init;
912913
const char *parent_names[2];
@@ -934,6 +935,29 @@ static int vc5_probe(struct i2c_client *client, const struct i2c_device_id *id)
934935
return dev_err_probe(&client->dev, PTR_ERR(vc5->regmap),
935936
"failed to allocate register map\n");
936937

938+
ret = of_property_read_u32(client->dev.of_node, "idt,shutdown", &sd);
939+
if (!ret) {
940+
src_mask |= VC5_PRIM_SRC_SHDN_EN_GBL_SHDN;
941+
if (sd)
942+
src_val |= VC5_PRIM_SRC_SHDN_EN_GBL_SHDN;
943+
} else if (ret != -EINVAL) {
944+
return dev_err_probe(&client->dev, ret,
945+
"could not read idt,shutdown\n");
946+
}
947+
948+
ret = of_property_read_u32(client->dev.of_node,
949+
"idt,output-enable-active", &oe);
950+
if (!ret) {
951+
src_mask |= VC5_PRIM_SRC_SHDN_SP;
952+
if (oe)
953+
src_val |= VC5_PRIM_SRC_SHDN_SP;
954+
} else if (ret != -EINVAL) {
955+
return dev_err_probe(&client->dev, ret,
956+
"could not read idt,output-enable-active\n");
957+
}
958+
959+
regmap_update_bits(vc5->regmap, VC5_PRIM_SRC_SHDN, src_mask, src_val);
960+
937961
/* Register clock input mux */
938962
memset(&init, 0, sizeof(init));
939963

0 commit comments

Comments
 (0)