Message ID | 20210918120934.28252-3-sven@svenpeter.dev (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | usb: typec: tipd: Add Apple M1 support | expand |
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Hi, On Sat, Sep 18, 2021 at 02:09:27PM +0200, Sven Peter wrote: > Apple M1 machines come with a variant of the TI TPS6598x and will need > some changes to the current logic. Let's prepare for that by setting up > the infrastructure required to support different variants of this chip > identified by the DT compatible. I think in this case it would make sense to just squash this into the next patch. > Signed-off-by: Sven Peter <sven@svenpeter.dev> > --- > drivers/usb/typec/tipd/core.c | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > index 21b3ae25c76d..656020e7f533 100644 > --- a/drivers/usb/typec/tipd/core.c > +++ b/drivers/usb/typec/tipd/core.c > @@ -9,6 +9,7 @@ > #include <linux/i2c.h> > #include <linux/acpi.h> > #include <linux/module.h> > +#include <linux/of_device.h> > #include <linux/power_supply.h> > #include <linux/regmap.h> > #include <linux/interrupt.h> > @@ -76,6 +77,10 @@ static const char *const modes[] = { > /* Unrecognized commands will be replaced with "!CMD" */ > #define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321) > > +struct tps6598x_hw { > +}; Black line here. > +static const struct tps6598x_hw ti_tps6598x_data; > + > struct tps6598x { > struct device *dev; > struct regmap *regmap; > @@ -91,6 +96,8 @@ struct tps6598x { > struct power_supply *psy; > struct power_supply_desc psy_desc; > enum power_supply_usb_type usb_type; > + > + const struct tps6598x_hw *hw; > }; > > static enum power_supply_property tps6598x_psy_props[] = { > @@ -590,6 +597,13 @@ static int tps6598x_probe(struct i2c_client *client) > if (!tps) > return -ENOMEM; > > + if (client->dev.of_node) > + tps->hw = of_device_get_match_data(&client->dev); > + else > + tps->hw = &ti_tps6598x_data; > + if (!tps->hw) > + return -EINVAL; tps->hw = of_device_get_match_data(&client->dev); if (!tps->hw) tps->hw = &ti_tps6598x_data; > mutex_init(&tps->lock); > tps->dev = &client->dev; > > @@ -729,8 +743,11 @@ static int tps6598x_remove(struct i2c_client *client) > return 0; > } > > +static const struct tps6598x_hw ti_tps6598x_data = { > +}; You could also move that above tps6598x_probe() and get rid of the forward declaration. > static const struct of_device_id tps6598x_of_match[] = { > - { .compatible = "ti,tps6598x", }, > + { .compatible = "ti,tps6598x", .data = &ti_tps6598x_data }, > {} > }; > MODULE_DEVICE_TABLE(of, tps6598x_of_match); thanks,
Hi, Thanks a lot for quick review! On Tue, Sep 21, 2021, at 15:10, Heikki Krogerus wrote: > Hi, > > On Sat, Sep 18, 2021 at 02:09:27PM +0200, Sven Peter wrote: >> Apple M1 machines come with a variant of the TI TPS6598x and will need >> some changes to the current logic. Let's prepare for that by setting up >> the infrastructure required to support different variants of this chip >> identified by the DT compatible. > > I think in this case it would make sense to just squash this into the > next patch. Sure, and taking into account your review for the later patches I will probably squash most of them into a single commit now. > >> Signed-off-by: Sven Peter <sven@svenpeter.dev> >> --- >> drivers/usb/typec/tipd/core.c | 19 ++++++++++++++++++- >> 1 file changed, 18 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c >> index 21b3ae25c76d..656020e7f533 100644 >> --- a/drivers/usb/typec/tipd/core.c >> +++ b/drivers/usb/typec/tipd/core.c >> @@ -9,6 +9,7 @@ >> #include <linux/i2c.h> >> #include <linux/acpi.h> >> #include <linux/module.h> >> +#include <linux/of_device.h> >> #include <linux/power_supply.h> >> #include <linux/regmap.h> >> #include <linux/interrupt.h> >> @@ -76,6 +77,10 @@ static const char *const modes[] = { >> /* Unrecognized commands will be replaced with "!CMD" */ >> #define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321) >> >> +struct tps6598x_hw { >> +}; > > Black line here. > >> +static const struct tps6598x_hw ti_tps6598x_data; >> + >> struct tps6598x { >> struct device *dev; >> struct regmap *regmap; >> @@ -91,6 +96,8 @@ struct tps6598x { >> struct power_supply *psy; >> struct power_supply_desc psy_desc; >> enum power_supply_usb_type usb_type; >> + >> + const struct tps6598x_hw *hw; >> }; >> >> static enum power_supply_property tps6598x_psy_props[] = { >> @@ -590,6 +597,13 @@ static int tps6598x_probe(struct i2c_client *client) >> if (!tps) >> return -ENOMEM; >> >> + if (client->dev.of_node) >> + tps->hw = of_device_get_match_data(&client->dev); >> + else >> + tps->hw = &ti_tps6598x_data; >> + if (!tps->hw) >> + return -EINVAL; > > tps->hw = of_device_get_match_data(&client->dev); > if (!tps->hw) > tps->hw = &ti_tps6598x_data; > Ah yes, that's indeed much nicer! >> mutex_init(&tps->lock); >> tps->dev = &client->dev; >> >> @@ -729,8 +743,11 @@ static int tps6598x_remove(struct i2c_client *client) >> return 0; >> } >> >> +static const struct tps6598x_hw ti_tps6598x_data = { >> +}; > > You could also move that above tps6598x_probe() and get rid of the > forward declaration. Ack. Best, Sven
diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 21b3ae25c76d..656020e7f533 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -9,6 +9,7 @@ #include <linux/i2c.h> #include <linux/acpi.h> #include <linux/module.h> +#include <linux/of_device.h> #include <linux/power_supply.h> #include <linux/regmap.h> #include <linux/interrupt.h> @@ -76,6 +77,10 @@ static const char *const modes[] = { /* Unrecognized commands will be replaced with "!CMD" */ #define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321) +struct tps6598x_hw { +}; +static const struct tps6598x_hw ti_tps6598x_data; + struct tps6598x { struct device *dev; struct regmap *regmap; @@ -91,6 +96,8 @@ struct tps6598x { struct power_supply *psy; struct power_supply_desc psy_desc; enum power_supply_usb_type usb_type; + + const struct tps6598x_hw *hw; }; static enum power_supply_property tps6598x_psy_props[] = { @@ -590,6 +597,13 @@ static int tps6598x_probe(struct i2c_client *client) if (!tps) return -ENOMEM; + if (client->dev.of_node) + tps->hw = of_device_get_match_data(&client->dev); + else + tps->hw = &ti_tps6598x_data; + if (!tps->hw) + return -EINVAL; + mutex_init(&tps->lock); tps->dev = &client->dev; @@ -729,8 +743,11 @@ static int tps6598x_remove(struct i2c_client *client) return 0; } +static const struct tps6598x_hw ti_tps6598x_data = { +}; + static const struct of_device_id tps6598x_of_match[] = { - { .compatible = "ti,tps6598x", }, + { .compatible = "ti,tps6598x", .data = &ti_tps6598x_data }, {} }; MODULE_DEVICE_TABLE(of, tps6598x_of_match);
Apple M1 machines come with a variant of the TI TPS6598x and will need some changes to the current logic. Let's prepare for that by setting up the infrastructure required to support different variants of this chip identified by the DT compatible. Signed-off-by: Sven Peter <sven@svenpeter.dev> --- drivers/usb/typec/tipd/core.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)