Biggest news is not a patch this time

* I2C has now a co-maintainer taking care of the host drivers. Welcome
   Andi Shyti and have fun!
 * platform remove callback converted to return void in drivers
 * simplify drivers by using devm_clk_get_enabled()
 * introduce i2c_get_match_data() to avoid more boilerplate code
   (especially since the core stopped delivering an i2c_device_id)
 * and the usual bunch of driver updates
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAmShZJ0ACgkQFA3kzBSg
 Kbbcaw/9ERpYjDr3ILftlDDAz3hKnmMiFNdwgTxwxnFb8xzRi4vBr6mOIUQUiuNe
 ks+Zq8JVu9+LklKzDbYSV8HM7wId2MYK7m/zoNDB3C0nIv1iGxTW4HM4BDF/TRkd
 /NBWT29dmG2DYb0cOp66thZXSi01qi0iqD+hraa6Z8HV+mKjHTYCtgaqvxF6XKEU
 GJWL8c9brbBc6nFkszQz/q8GGbh3sXi2shLE/KeF/B5o1z0qTNP9szUW1hwMCMIE
 aB/EAzGtMsJ89fi1qphACFAigTUMzRPFrvUHAQUMOEXZlpWUE7T9Hx2raJU0iOme
 tCjfpqm0yVKueBcOEKZfn+O2BfhGpMBdz3f01kvELtUolGzOiqYUF4MiWqiuK7eJ
 IppUZiArgP0BMo94qa2MnGlD1jWLTWJPqYeuqKGLjBAhJMrcMEXqKpuwDS1CRr6h
 KKfJPNZFB7BFNIq5Qs1GPpnlRRnzmjzIusAI55X8xIfAj3DHuluRP5QGY2eOSbnK
 P/2bQnUh83ApJURotihH1hToIXIhxczj2UYHs+m4y6AfWtEh8I/ePp+DrvVoyKQl
 UCRRHPgEpW9vHtW28vPMARJ/dPjqfaa6Kpp1i9NBoAiZsm4Sl7sQaRjTXn/1FuCO
 cK3cePwJsfFYn/VPKccM5khmF/v70U09Fb2um3yY5X7vJDUoQzc=
 =60K9
 -----END PGP SIGNATURE-----

Merge tag 'i2c-for-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c updates from Wolfram Sang:

 - I2C has now a co-maintainer taking care of the host drivers. Welcome
   Andi Shyti and have fun!

 - platform remove callback converted to return void in drivers

 - simplify drivers by using devm_clk_get_enabled()

 - introduce i2c_get_match_data() to avoid more boilerplate code
   (especially since the core stopped delivering an i2c_device_id)

 - and the usual bunch of driver updates

* tag 'i2c-for-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (38 commits)
  i2c: uniphier: Use devm_clk_get_enabled()
  i2c: uniphier-f: Use devm_clk_get_enabled()
  i2c: owl: Use devm_clk_get_enabled()
  i2c: lpc2k: Use devm_clk_get_enabled()
  i2c: hix5hd2: Use devm_clk_get_enabled()
  i2c: sun6i-p2wi: Use devm_clk_get_enabled()
  i2c: pasemi-platform: Use devm_clk_get_enabled()
  i2c: mt7621: Use devm_clk_get_enabled()
  i2c: xiic: Use devm_clk_get_enabled()
  i2c: davinci: Use platform table macro over module_alias
  i2c: ocores: use devm_ managed clks
  i2c: nomadik: Use dev_err_probe() whenever possible
  i2c: nomadik: Use devm_clk_get_enabled()
  i2c: nomadik: Remove unnecessary goto label
  usb: typec: ucsi: Mark dGPUs as DEVICE scope
  i2c: wmt: Use devm_platform_get_and_ioremap_resource()
  i2c: versatile: Use devm_platform_get_and_ioremap_resource()
  i2c: hix5hd2: Add I2C_M_STOP flag support for i2c-hix5hd2 driver.
  i2c: mpc: Use of_property_read_reg() to parse "reg"
  i2c: imx-lpi2c: Don't open-code DIV_ROUND_UP
  ...
This commit is contained in:
Linus Torvalds 2023-07-02 10:22:38 -07:00
commit 5def00ca25
103 changed files with 584 additions and 726 deletions

View File

@ -46,7 +46,7 @@ Supported adapters:
* Intel Emmitsburg (PCH) * Intel Emmitsburg (PCH)
* Intel Alder Lake (PCH) * Intel Alder Lake (PCH)
* Intel Raptor Lake (PCH) * Intel Raptor Lake (PCH)
* Intel Meteor Lake (SOC) * Intel Meteor Lake (SOC and PCH)
Datasheets: Publicly available at the Intel website Datasheets: Publicly available at the Intel website

View File

@ -157,7 +157,7 @@ config I2C_I801
Emmitsburg (PCH) Emmitsburg (PCH)
Alder Lake (PCH) Alder Lake (PCH)
Raptor Lake (PCH) Raptor Lake (PCH)
Meteor Lake (SOC) Meteor Lake (SOC and PCH)
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called i2c-i801. will be called i2c-i801.

View File

@ -465,14 +465,12 @@ static int altr_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int altr_i2c_remove(struct platform_device *pdev) static void altr_i2c_remove(struct platform_device *pdev)
{ {
struct altr_i2c_dev *idev = platform_get_drvdata(pdev); struct altr_i2c_dev *idev = platform_get_drvdata(pdev);
clk_disable_unprepare(idev->i2c_clk); clk_disable_unprepare(idev->i2c_clk);
i2c_del_adapter(&idev->adapter); i2c_del_adapter(&idev->adapter);
return 0;
} }
/* Match table for of_platform binding */ /* Match table for of_platform binding */
@ -484,7 +482,7 @@ MODULE_DEVICE_TABLE(of, altr_i2c_of_match);
static struct platform_driver altr_i2c_driver = { static struct platform_driver altr_i2c_driver = {
.probe = altr_i2c_probe, .probe = altr_i2c_probe,
.remove = altr_i2c_remove, .remove_new = altr_i2c_remove,
.driver = { .driver = {
.name = "altera-i2c", .name = "altera-i2c",
.of_match_table = altr_i2c_of_match, .of_match_table = altr_i2c_of_match,

View File

@ -322,7 +322,7 @@ static int i2c_amd_probe(struct platform_device *pdev)
return ret; return ret;
} }
static int i2c_amd_remove(struct platform_device *pdev) static void i2c_amd_remove(struct platform_device *pdev)
{ {
struct amd_i2c_dev *i2c_dev = platform_get_drvdata(pdev); struct amd_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
struct amd_i2c_common *i2c_common = &i2c_dev->common; struct amd_i2c_common *i2c_common = &i2c_dev->common;
@ -336,7 +336,6 @@ static int i2c_amd_remove(struct platform_device *pdev)
i2c_unlock_bus(&i2c_dev->adap, I2C_LOCK_ROOT_ADAPTER); i2c_unlock_bus(&i2c_dev->adap, I2C_LOCK_ROOT_ADAPTER);
i2c_del_adapter(&i2c_dev->adap); i2c_del_adapter(&i2c_dev->adap);
return 0;
} }
static const struct acpi_device_id i2c_amd_acpi_match[] = { static const struct acpi_device_id i2c_amd_acpi_match[] = {
@ -347,7 +346,7 @@ MODULE_DEVICE_TABLE(acpi, i2c_amd_acpi_match);
static struct platform_driver i2c_amd_plat_driver = { static struct platform_driver i2c_amd_plat_driver = {
.probe = i2c_amd_probe, .probe = i2c_amd_probe,
.remove = i2c_amd_remove, .remove_new = i2c_amd_remove,
.driver = { .driver = {
.name = "i2c_amd_mp2", .name = "i2c_amd_mp2",
.acpi_match_table = ACPI_PTR(i2c_amd_acpi_match), .acpi_match_table = ACPI_PTR(i2c_amd_acpi_match),

View File

@ -1061,7 +1061,7 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev)
return 0; return 0;
} }
static int aspeed_i2c_remove_bus(struct platform_device *pdev) static void aspeed_i2c_remove_bus(struct platform_device *pdev)
{ {
struct aspeed_i2c_bus *bus = platform_get_drvdata(pdev); struct aspeed_i2c_bus *bus = platform_get_drvdata(pdev);
unsigned long flags; unsigned long flags;
@ -1077,13 +1077,11 @@ static int aspeed_i2c_remove_bus(struct platform_device *pdev)
reset_control_assert(bus->rst); reset_control_assert(bus->rst);
i2c_del_adapter(&bus->adap); i2c_del_adapter(&bus->adap);
return 0;
} }
static struct platform_driver aspeed_i2c_bus_driver = { static struct platform_driver aspeed_i2c_bus_driver = {
.probe = aspeed_i2c_probe_bus, .probe = aspeed_i2c_probe_bus,
.remove = aspeed_i2c_remove_bus, .remove_new = aspeed_i2c_remove_bus,
.driver = { .driver = {
.name = "aspeed-i2c-bus", .name = "aspeed-i2c-bus",
.of_match_table = aspeed_i2c_bus_of_table, .of_match_table = aspeed_i2c_bus_of_table,

View File

@ -273,7 +273,7 @@ static int at91_twi_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int at91_twi_remove(struct platform_device *pdev) static void at91_twi_remove(struct platform_device *pdev)
{ {
struct at91_twi_dev *dev = platform_get_drvdata(pdev); struct at91_twi_dev *dev = platform_get_drvdata(pdev);
@ -282,8 +282,6 @@ static int at91_twi_remove(struct platform_device *pdev)
pm_runtime_disable(dev->dev); pm_runtime_disable(dev->dev);
pm_runtime_set_suspended(dev->dev); pm_runtime_set_suspended(dev->dev);
return 0;
} }
static int __maybe_unused at91_twi_runtime_suspend(struct device *dev) static int __maybe_unused at91_twi_runtime_suspend(struct device *dev)
@ -342,7 +340,7 @@ static const struct dev_pm_ops __maybe_unused at91_twi_pm = {
static struct platform_driver at91_twi_driver = { static struct platform_driver at91_twi_driver = {
.probe = at91_twi_probe, .probe = at91_twi_probe,
.remove = at91_twi_remove, .remove_new = at91_twi_remove,
.id_table = at91_twi_devtypes, .id_table = at91_twi_devtypes,
.driver = { .driver = {
.name = "at91_i2c", .name = "at91_i2c",

View File

@ -334,13 +334,12 @@ i2c_au1550_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int i2c_au1550_remove(struct platform_device *pdev) static void i2c_au1550_remove(struct platform_device *pdev)
{ {
struct i2c_au1550_data *priv = platform_get_drvdata(pdev); struct i2c_au1550_data *priv = platform_get_drvdata(pdev);
i2c_del_adapter(&priv->adap); i2c_del_adapter(&priv->adap);
i2c_au1550_disable(priv); i2c_au1550_disable(priv);
return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
@ -379,7 +378,7 @@ static struct platform_driver au1xpsc_smbus_driver = {
.pm = AU1XPSC_SMBUS_PMOPS, .pm = AU1XPSC_SMBUS_PMOPS,
}, },
.probe = i2c_au1550_probe, .probe = i2c_au1550_probe,
.remove = i2c_au1550_remove, .remove_new = i2c_au1550_remove,
}; };
module_platform_driver(au1xpsc_smbus_driver); module_platform_driver(au1xpsc_smbus_driver);

View File

@ -804,14 +804,12 @@ error_disable_clk:
return ret; return ret;
} }
static int axxia_i2c_remove(struct platform_device *pdev) static void axxia_i2c_remove(struct platform_device *pdev)
{ {
struct axxia_i2c_dev *idev = platform_get_drvdata(pdev); struct axxia_i2c_dev *idev = platform_get_drvdata(pdev);
clk_disable_unprepare(idev->i2c_clk); clk_disable_unprepare(idev->i2c_clk);
i2c_del_adapter(&idev->adapter); i2c_del_adapter(&idev->adapter);
return 0;
} }
/* Match table for of_platform binding */ /* Match table for of_platform binding */
@ -824,7 +822,7 @@ MODULE_DEVICE_TABLE(of, axxia_i2c_of_match);
static struct platform_driver axxia_i2c_driver = { static struct platform_driver axxia_i2c_driver = {
.probe = axxia_i2c_probe, .probe = axxia_i2c_probe,
.remove = axxia_i2c_remove, .remove_new = axxia_i2c_remove,
.driver = { .driver = {
.name = "axxia-i2c", .name = "axxia-i2c",
.of_match_table = axxia_i2c_of_match, .of_match_table = axxia_i2c_of_match,

View File

@ -1107,7 +1107,7 @@ static int bcm_iproc_i2c_probe(struct platform_device *pdev)
return i2c_add_adapter(adap); return i2c_add_adapter(adap);
} }
static int bcm_iproc_i2c_remove(struct platform_device *pdev) static void bcm_iproc_i2c_remove(struct platform_device *pdev)
{ {
struct bcm_iproc_i2c_dev *iproc_i2c = platform_get_drvdata(pdev); struct bcm_iproc_i2c_dev *iproc_i2c = platform_get_drvdata(pdev);
@ -1123,8 +1123,6 @@ static int bcm_iproc_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(&iproc_i2c->adapter); i2c_del_adapter(&iproc_i2c->adapter);
bcm_iproc_i2c_enable_disable(iproc_i2c, false); bcm_iproc_i2c_enable_disable(iproc_i2c, false);
return 0;
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
@ -1260,7 +1258,7 @@ static struct platform_driver bcm_iproc_i2c_driver = {
.pm = BCM_IPROC_I2C_PM_OPS, .pm = BCM_IPROC_I2C_PM_OPS,
}, },
.probe = bcm_iproc_i2c_probe, .probe = bcm_iproc_i2c_probe,
.remove = bcm_iproc_i2c_remove, .remove_new = bcm_iproc_i2c_remove,
}; };
module_platform_driver(bcm_iproc_i2c_driver); module_platform_driver(bcm_iproc_i2c_driver);

View File

@ -859,13 +859,11 @@ probe_disable_clk:
return rc; return rc;
} }
static int bcm_kona_i2c_remove(struct platform_device *pdev) static void bcm_kona_i2c_remove(struct platform_device *pdev)
{ {
struct bcm_kona_i2c_dev *dev = platform_get_drvdata(pdev); struct bcm_kona_i2c_dev *dev = platform_get_drvdata(pdev);
i2c_del_adapter(&dev->adapter); i2c_del_adapter(&dev->adapter);
return 0;
} }
static const struct of_device_id bcm_kona_i2c_of_match[] = { static const struct of_device_id bcm_kona_i2c_of_match[] = {
@ -880,7 +878,7 @@ static struct platform_driver bcm_kona_i2c_driver = {
.of_match_table = bcm_kona_i2c_of_match, .of_match_table = bcm_kona_i2c_of_match,
}, },
.probe = bcm_kona_i2c_probe, .probe = bcm_kona_i2c_probe,
.remove = bcm_kona_i2c_remove, .remove_new = bcm_kona_i2c_remove,
}; };
module_platform_driver(bcm_kona_i2c_driver); module_platform_driver(bcm_kona_i2c_driver);

View File

@ -503,7 +503,7 @@ err_put_exclusive_rate:
return ret; return ret;
} }
static int bcm2835_i2c_remove(struct platform_device *pdev) static void bcm2835_i2c_remove(struct platform_device *pdev)
{ {
struct bcm2835_i2c_dev *i2c_dev = platform_get_drvdata(pdev); struct bcm2835_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
@ -512,8 +512,6 @@ static int bcm2835_i2c_remove(struct platform_device *pdev)
free_irq(i2c_dev->irq, i2c_dev); free_irq(i2c_dev->irq, i2c_dev);
i2c_del_adapter(&i2c_dev->adapter); i2c_del_adapter(&i2c_dev->adapter);
return 0;
} }
static const struct of_device_id bcm2835_i2c_of_match[] = { static const struct of_device_id bcm2835_i2c_of_match[] = {
@ -525,7 +523,7 @@ MODULE_DEVICE_TABLE(of, bcm2835_i2c_of_match);
static struct platform_driver bcm2835_i2c_driver = { static struct platform_driver bcm2835_i2c_driver = {
.probe = bcm2835_i2c_probe, .probe = bcm2835_i2c_probe,
.remove = bcm2835_i2c_remove, .remove_new = bcm2835_i2c_remove,
.driver = { .driver = {
.name = "i2c-bcm2835", .name = "i2c-bcm2835",
.of_match_table = bcm2835_i2c_of_match, .of_match_table = bcm2835_i2c_of_match,

View File

@ -690,12 +690,11 @@ probe_errorout:
return rc; return rc;
} }
static int brcmstb_i2c_remove(struct platform_device *pdev) static void brcmstb_i2c_remove(struct platform_device *pdev)
{ {
struct brcmstb_i2c_dev *dev = platform_get_drvdata(pdev); struct brcmstb_i2c_dev *dev = platform_get_drvdata(pdev);
i2c_del_adapter(&dev->adapter); i2c_del_adapter(&dev->adapter);
return 0;
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
@ -736,7 +735,7 @@ static struct platform_driver brcmstb_i2c_driver = {
.pm = &brcmstb_i2c_pm, .pm = &brcmstb_i2c_pm,
}, },
.probe = brcmstb_i2c_probe, .probe = brcmstb_i2c_probe,
.remove = brcmstb_i2c_remove, .remove_new = brcmstb_i2c_remove,
}; };
module_platform_driver(brcmstb_i2c_driver); module_platform_driver(brcmstb_i2c_driver);

View File

@ -1415,7 +1415,7 @@ err_clk_dis:
* *
* Return: 0 always * Return: 0 always
*/ */
static int cdns_i2c_remove(struct platform_device *pdev) static void cdns_i2c_remove(struct platform_device *pdev)
{ {
struct cdns_i2c *id = platform_get_drvdata(pdev); struct cdns_i2c *id = platform_get_drvdata(pdev);
@ -1427,8 +1427,6 @@ static int cdns_i2c_remove(struct platform_device *pdev)
clk_notifier_unregister(id->clk, &id->clk_rate_change_nb); clk_notifier_unregister(id->clk, &id->clk_rate_change_nb);
reset_control_assert(id->reset); reset_control_assert(id->reset);
clk_disable_unprepare(id->clk); clk_disable_unprepare(id->clk);
return 0;
} }
static struct platform_driver cdns_i2c_drv = { static struct platform_driver cdns_i2c_drv = {
@ -1438,7 +1436,7 @@ static struct platform_driver cdns_i2c_drv = {
.pm = &cdns_i2c_dev_pm_ops, .pm = &cdns_i2c_dev_pm_ops,
}, },
.probe = cdns_i2c_probe, .probe = cdns_i2c_probe,
.remove = cdns_i2c_remove, .remove_new = cdns_i2c_remove,
}; };
module_platform_driver(cdns_i2c_drv); module_platform_driver(cdns_i2c_drv);

View File

@ -200,13 +200,11 @@ static const struct i2c_algorithm cbus_i2c_algo = {
.functionality = cbus_i2c_func, .functionality = cbus_i2c_func,
}; };
static int cbus_i2c_remove(struct platform_device *pdev) static void cbus_i2c_remove(struct platform_device *pdev)
{ {
struct i2c_adapter *adapter = platform_get_drvdata(pdev); struct i2c_adapter *adapter = platform_get_drvdata(pdev);
i2c_del_adapter(adapter); i2c_del_adapter(adapter);
return 0;
} }
static int cbus_i2c_probe(struct platform_device *pdev) static int cbus_i2c_probe(struct platform_device *pdev)
@ -266,7 +264,7 @@ MODULE_DEVICE_TABLE(of, i2c_cbus_dt_ids);
static struct platform_driver cbus_i2c_driver = { static struct platform_driver cbus_i2c_driver = {
.probe = cbus_i2c_probe, .probe = cbus_i2c_probe,
.remove = cbus_i2c_remove, .remove_new = cbus_i2c_remove,
.driver = { .driver = {
.name = "i2c-cbus-gpio", .name = "i2c-cbus-gpio",
.of_match_table = of_match_ptr(i2c_cbus_dt_ids), .of_match_table = of_match_ptr(i2c_cbus_dt_ids),

View File

@ -529,15 +529,13 @@ remove_irq_domain:
return ret; return ret;
} }
static int cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev) static void cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev)
{ {
struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev); struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev);
i2c_unregister_device(adap->client); i2c_unregister_device(adap->client);
i2c_del_adapter(&adap->adapter); i2c_del_adapter(&adap->adapter);
irq_domain_remove(adap->irq_domain); irq_domain_remove(adap->irq_domain);
return 0;
} }
static const struct platform_device_id cht_wc_i2c_adap_id_table[] = { static const struct platform_device_id cht_wc_i2c_adap_id_table[] = {
@ -548,7 +546,7 @@ MODULE_DEVICE_TABLE(platform, cht_wc_i2c_adap_id_table);
static struct platform_driver cht_wc_i2c_adap_driver = { static struct platform_driver cht_wc_i2c_adap_driver = {
.probe = cht_wc_i2c_adap_i2c_probe, .probe = cht_wc_i2c_adap_i2c_probe,
.remove = cht_wc_i2c_adap_i2c_remove, .remove_new = cht_wc_i2c_adap_i2c_remove,
.driver = { .driver = {
.name = "cht_wcove_ext_chgr", .name = "cht_wcove_ext_chgr",
}, },

View File

@ -676,7 +676,7 @@ out_free:
return result; return result;
} }
static int cpm_i2c_remove(struct platform_device *ofdev) static void cpm_i2c_remove(struct platform_device *ofdev)
{ {
struct cpm_i2c *cpm = platform_get_drvdata(ofdev); struct cpm_i2c *cpm = platform_get_drvdata(ofdev);
@ -685,8 +685,6 @@ static int cpm_i2c_remove(struct platform_device *ofdev)
cpm_i2c_shutdown(cpm); cpm_i2c_shutdown(cpm);
kfree(cpm); kfree(cpm);
return 0;
} }
static const struct of_device_id cpm_i2c_match[] = { static const struct of_device_id cpm_i2c_match[] = {
@ -703,7 +701,7 @@ MODULE_DEVICE_TABLE(of, cpm_i2c_match);
static struct platform_driver cpm_i2c_driver = { static struct platform_driver cpm_i2c_driver = {
.probe = cpm_i2c_probe, .probe = cpm_i2c_probe,
.remove = cpm_i2c_remove, .remove_new = cpm_i2c_remove,
.driver = { .driver = {
.name = "fsl-i2c-cpm", .name = "fsl-i2c-cpm",
.of_match_table = cpm_i2c_match, .of_match_table = cpm_i2c_match,

View File

@ -283,13 +283,11 @@ static int ec_i2c_probe(struct platform_device *pdev)
return err; return err;
} }
static int ec_i2c_remove(struct platform_device *dev) static void ec_i2c_remove(struct platform_device *dev)
{ {
struct ec_i2c_device *bus = platform_get_drvdata(dev); struct ec_i2c_device *bus = platform_get_drvdata(dev);
i2c_del_adapter(&bus->adap); i2c_del_adapter(&bus->adap);
return 0;
} }
static const struct of_device_id cros_ec_i2c_of_match[] __maybe_unused = { static const struct of_device_id cros_ec_i2c_of_match[] __maybe_unused = {
@ -306,7 +304,7 @@ MODULE_DEVICE_TABLE(acpi, cros_ec_i2c_tunnel_acpi_id);
static struct platform_driver ec_i2c_tunnel_driver = { static struct platform_driver ec_i2c_tunnel_driver = {
.probe = ec_i2c_probe, .probe = ec_i2c_probe,
.remove = ec_i2c_remove, .remove_new = ec_i2c_remove,
.driver = { .driver = {
.name = "cros-ec-i2c-tunnel", .name = "cros-ec-i2c-tunnel",
.acpi_match_table = ACPI_PTR(cros_ec_i2c_tunnel_acpi_id), .acpi_match_table = ACPI_PTR(cros_ec_i2c_tunnel_acpi_id),

View File

@ -767,12 +767,9 @@ static int davinci_i2c_probe(struct platform_device *pdev)
if (irq < 0) if (irq < 0)
return dev_err_probe(&pdev->dev, irq, "can't get irq resource\n"); return dev_err_probe(&pdev->dev, irq, "can't get irq resource\n");
dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_i2c_dev), dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
GFP_KERNEL); if (!dev)
if (!dev) {
dev_err(&pdev->dev, "Memory allocation failed\n");
return -ENOMEM; return -ENOMEM;
}
init_completion(&dev->cmd_complete); init_completion(&dev->cmd_complete);
@ -885,7 +882,7 @@ err_pm:
return r; return r;
} }
static int davinci_i2c_remove(struct platform_device *pdev) static void davinci_i2c_remove(struct platform_device *pdev)
{ {
struct davinci_i2c_dev *dev = platform_get_drvdata(pdev); struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
int ret; int ret;
@ -894,17 +891,15 @@ static int davinci_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(&dev->adapter); i2c_del_adapter(&dev->adapter);
ret = pm_runtime_resume_and_get(&pdev->dev); ret = pm_runtime_get_sync(&pdev->dev);
if (ret < 0) if (ret < 0)
return ret; dev_err(&pdev->dev, "Failed to resume device\n");
else
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, 0); davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, 0);
pm_runtime_dont_use_autosuspend(dev->dev); pm_runtime_dont_use_autosuspend(dev->dev);
pm_runtime_put_sync(dev->dev); pm_runtime_put_sync(dev->dev);
pm_runtime_disable(dev->dev); pm_runtime_disable(dev->dev);
return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
@ -940,12 +935,16 @@ static const struct dev_pm_ops davinci_i2c_pm = {
#define davinci_i2c_pm_ops NULL #define davinci_i2c_pm_ops NULL
#endif #endif
/* work with hotplug and coldplug */ static const struct platform_device_id davinci_i2c_driver_ids[] = {
MODULE_ALIAS("platform:i2c_davinci"); { .name = "i2c_davinci", },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(platform, davinci_i2c_driver_ids);
static struct platform_driver davinci_i2c_driver = { static struct platform_driver davinci_i2c_driver = {
.probe = davinci_i2c_probe, .probe = davinci_i2c_probe,
.remove = davinci_i2c_remove, .remove_new = davinci_i2c_remove,
.id_table = davinci_i2c_driver_ids,
.driver = { .driver = {
.name = "i2c_davinci", .name = "i2c_davinci",
.pm = davinci_i2c_pm_ops, .pm = davinci_i2c_pm_ops,

View File

@ -575,6 +575,14 @@ int i2c_dw_set_fifo_size(struct dw_i2c_dev *dev)
unsigned int param; unsigned int param;
int ret; int ret;
/* DW_IC_COMP_PARAM_1 not implement for IP issue */
if ((dev->flags & MODEL_MASK) == MODEL_WANGXUN_SP) {
dev->tx_fifo_depth = TXGBE_TX_FIFO_DEPTH;
dev->rx_fifo_depth = TXGBE_RX_FIFO_DEPTH;
return 0;
}
/* /*
* Try to detect the FIFO depth if not set by interface driver, * Try to detect the FIFO depth if not set by interface driver,
* the depth could be from 2 to 256 from HW spec. * the depth could be from 2 to 256 from HW spec.

View File

@ -304,6 +304,7 @@ struct dw_i2c_dev {
#define MODEL_MSCC_OCELOT BIT(8) #define MODEL_MSCC_OCELOT BIT(8)
#define MODEL_BAIKAL_BT1 BIT(9) #define MODEL_BAIKAL_BT1 BIT(9)
#define MODEL_AMD_NAVI_GPU BIT(10) #define MODEL_AMD_NAVI_GPU BIT(10)
#define MODEL_WANGXUN_SP BIT(11)
#define MODEL_MASK GENMASK(11, 8) #define MODEL_MASK GENMASK(11, 8)
/* /*
@ -313,6 +314,9 @@ struct dw_i2c_dev {
#define AMD_UCSI_INTR_REG 0x474 #define AMD_UCSI_INTR_REG 0x474
#define AMD_UCSI_INTR_EN 0xd #define AMD_UCSI_INTR_EN 0xd
#define TXGBE_TX_FIFO_DEPTH 4
#define TXGBE_RX_FIFO_DEPTH 0
struct i2c_dw_semaphore_callbacks { struct i2c_dw_semaphore_callbacks {
int (*probe)(struct dw_i2c_dev *dev); int (*probe)(struct dw_i2c_dev *dev);
void (*remove)(struct dw_i2c_dev *dev); void (*remove)(struct dw_i2c_dev *dev);

View File

@ -354,6 +354,68 @@ static int amd_i2c_dw_xfer_quirk(struct i2c_adapter *adap, struct i2c_msg *msgs,
return 0; return 0;
} }
static int i2c_dw_poll_tx_empty(struct dw_i2c_dev *dev)
{
u32 val;
return regmap_read_poll_timeout(dev->map, DW_IC_RAW_INTR_STAT, val,
val & DW_IC_INTR_TX_EMPTY,
100, 1000);
}
static int i2c_dw_poll_rx_full(struct dw_i2c_dev *dev)
{
u32 val;
return regmap_read_poll_timeout(dev->map, DW_IC_RAW_INTR_STAT, val,
val & DW_IC_INTR_RX_FULL,
100, 1000);
}
static int txgbe_i2c_dw_xfer_quirk(struct i2c_adapter *adap, struct i2c_msg *msgs,
int num_msgs)
{
struct dw_i2c_dev *dev = i2c_get_adapdata(adap);
int msg_idx, buf_len, data_idx, ret;
unsigned int val, stop = 0;
u8 *buf;
dev->msgs = msgs;
dev->msgs_num = num_msgs;
i2c_dw_xfer_init(dev);
regmap_write(dev->map, DW_IC_INTR_MASK, 0);
for (msg_idx = 0; msg_idx < num_msgs; msg_idx++) {
buf = msgs[msg_idx].buf;
buf_len = msgs[msg_idx].len;
for (data_idx = 0; data_idx < buf_len; data_idx++) {
if (msg_idx == num_msgs - 1 && data_idx == buf_len - 1)
stop |= BIT(9);
if (msgs[msg_idx].flags & I2C_M_RD) {
regmap_write(dev->map, DW_IC_DATA_CMD, 0x100 | stop);
ret = i2c_dw_poll_rx_full(dev);
if (ret)
return ret;
regmap_read(dev->map, DW_IC_DATA_CMD, &val);
buf[data_idx] = val;
} else {
ret = i2c_dw_poll_tx_empty(dev);
if (ret)
return ret;
regmap_write(dev->map, DW_IC_DATA_CMD,
buf[data_idx] | stop);
}
}
}
return num_msgs;
}
/* /*
* Initiate (and continue) low level master read/write transaction. * Initiate (and continue) low level master read/write transaction.
* This function is only called from i2c_dw_isr, and pumping i2c_msg * This function is only called from i2c_dw_isr, and pumping i2c_msg
@ -559,13 +621,19 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
pm_runtime_get_sync(dev->dev); pm_runtime_get_sync(dev->dev);
/* /*
* Initiate I2C message transfer when AMD NAVI GPU card is enabled, * Initiate I2C message transfer when polling mode is enabled,
* As it is polling based transfer mechanism, which does not support * As it is polling based transfer mechanism, which does not support
* interrupt based functionalities of existing DesignWare driver. * interrupt based functionalities of existing DesignWare driver.
*/ */
if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) { switch (dev->flags & MODEL_MASK) {
case MODEL_AMD_NAVI_GPU:
ret = amd_i2c_dw_xfer_quirk(adap, msgs, num); ret = amd_i2c_dw_xfer_quirk(adap, msgs, num);
goto done_nolock; goto done_nolock;
case MODEL_WANGXUN_SP:
ret = txgbe_i2c_dw_xfer_quirk(adap, msgs, num);
goto done_nolock;
default:
break;
} }
reinit_completion(&dev->cmd_complete); reinit_completion(&dev->cmd_complete);
@ -848,7 +916,7 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev)
return 0; return 0;
} }
static int amd_i2c_adap_quirk(struct dw_i2c_dev *dev) static int i2c_dw_poll_adap_quirk(struct dw_i2c_dev *dev)
{ {
struct i2c_adapter *adap = &dev->adapter; struct i2c_adapter *adap = &dev->adapter;
int ret; int ret;
@ -862,6 +930,17 @@ static int amd_i2c_adap_quirk(struct dw_i2c_dev *dev)
return ret; return ret;
} }
static bool i2c_dw_is_model_poll(struct dw_i2c_dev *dev)
{
switch (dev->flags & MODEL_MASK) {
case MODEL_AMD_NAVI_GPU:
case MODEL_WANGXUN_SP:
return true;
default:
return false;
}
}
int i2c_dw_probe_master(struct dw_i2c_dev *dev) int i2c_dw_probe_master(struct dw_i2c_dev *dev)
{ {
struct i2c_adapter *adap = &dev->adapter; struct i2c_adapter *adap = &dev->adapter;
@ -917,8 +996,8 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev)
adap->dev.parent = dev->dev; adap->dev.parent = dev->dev;
i2c_set_adapdata(adap, dev); i2c_set_adapdata(adap, dev);
if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) if (i2c_dw_is_model_poll(dev))
return amd_i2c_adap_quirk(dev); return i2c_dw_poll_adap_quirk(dev);
if (dev->flags & ACCESS_NO_IRQ_SUSPEND) { if (dev->flags & ACCESS_NO_IRQ_SUSPEND) {
irq_flags = IRQF_NO_SUSPEND; irq_flags = IRQF_NO_SUSPEND;

View File

@ -20,6 +20,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/power_supply.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
@ -234,6 +235,16 @@ static const struct dev_pm_ops i2c_dw_pm_ops = {
SET_RUNTIME_PM_OPS(i2c_dw_pci_runtime_suspend, i2c_dw_pci_runtime_resume, NULL) SET_RUNTIME_PM_OPS(i2c_dw_pci_runtime_suspend, i2c_dw_pci_runtime_resume, NULL)
}; };
static const struct property_entry dgpu_properties[] = {
/* USB-C doesn't power the system */
PROPERTY_ENTRY_U8("scope", POWER_SUPPLY_SCOPE_DEVICE),
{}
};
static const struct software_node dgpu_node = {
.properties = dgpu_properties,
};
static int i2c_dw_pci_probe(struct pci_dev *pdev, static int i2c_dw_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id) const struct pci_device_id *id)
{ {
@ -325,7 +336,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
} }
if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) { if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) {
dev->slave = i2c_new_ccgx_ucsi(&dev->adapter, dev->irq, NULL); dev->slave = i2c_new_ccgx_ucsi(&dev->adapter, dev->irq, &dgpu_node);
if (IS_ERR(dev->slave)) if (IS_ERR(dev->slave))
return dev_err_probe(dev->dev, PTR_ERR(dev->slave), return dev_err_probe(dev->dev, PTR_ERR(dev->slave),
"register UCSI failed\n"); "register UCSI failed\n");

View File

@ -168,6 +168,15 @@ static inline int dw_i2c_of_configure(struct platform_device *pdev)
} }
#endif #endif
static int txgbe_i2c_request_regs(struct dw_i2c_dev *dev)
{
dev->map = dev_get_regmap(dev->dev->parent, NULL);
if (!dev->map)
return -ENODEV;
return 0;
}
static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev) static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev)
{ {
pm_runtime_disable(dev->dev); pm_runtime_disable(dev->dev);
@ -185,6 +194,9 @@ static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev)
case MODEL_BAIKAL_BT1: case MODEL_BAIKAL_BT1:
ret = bt1_i2c_request_regs(dev); ret = bt1_i2c_request_regs(dev);
break; break;
case MODEL_WANGXUN_SP:
ret = txgbe_i2c_request_regs(dev);
break;
default: default:
dev->base = devm_platform_ioremap_resource(pdev, 0); dev->base = devm_platform_ioremap_resource(pdev, 0);
ret = PTR_ERR_OR_ZERO(dev->base); ret = PTR_ERR_OR_ZERO(dev->base);
@ -277,6 +289,9 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
dev->flags = (uintptr_t)device_get_match_data(&pdev->dev); dev->flags = (uintptr_t)device_get_match_data(&pdev->dev);
if (device_property_present(&pdev->dev, "wx,i2c-snps-model"))
dev->flags = MODEL_WANGXUN_SP;
dev->dev = &pdev->dev; dev->dev = &pdev->dev;
dev->irq = irq; dev->irq = irq;
platform_set_drvdata(pdev, dev); platform_set_drvdata(pdev, dev);
@ -384,7 +399,7 @@ exit_reset:
return ret; return ret;
} }
static int dw_i2c_plat_remove(struct platform_device *pdev) static void dw_i2c_plat_remove(struct platform_device *pdev)
{ {
struct dw_i2c_dev *dev = platform_get_drvdata(pdev); struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
@ -401,8 +416,6 @@ static int dw_i2c_plat_remove(struct platform_device *pdev)
i2c_dw_remove_lock_support(dev); i2c_dw_remove_lock_support(dev);
reset_control_assert(dev->rst); reset_control_assert(dev->rst);
return 0;
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
@ -481,7 +494,7 @@ MODULE_ALIAS("platform:i2c_designware");
static struct platform_driver dw_i2c_driver = { static struct platform_driver dw_i2c_driver = {
.probe = dw_i2c_plat_probe, .probe = dw_i2c_plat_probe,
.remove = dw_i2c_plat_remove, .remove_new = dw_i2c_plat_remove,
.driver = { .driver = {
.name = "i2c_designware", .name = "i2c_designware",
.of_match_table = of_match_ptr(dw_i2c_of_match), .of_match_table = of_match_ptr(dw_i2c_of_match),

View File

@ -347,14 +347,12 @@ static int dc_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int dc_i2c_remove(struct platform_device *pdev) static void dc_i2c_remove(struct platform_device *pdev)
{ {
struct dc_i2c *i2c = platform_get_drvdata(pdev); struct dc_i2c *i2c = platform_get_drvdata(pdev);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
clk_disable_unprepare(i2c->clk); clk_disable_unprepare(i2c->clk);
return 0;
} }
static const struct of_device_id dc_i2c_match[] = { static const struct of_device_id dc_i2c_match[] = {
@ -365,7 +363,7 @@ MODULE_DEVICE_TABLE(of, dc_i2c_match);
static struct platform_driver dc_i2c_driver = { static struct platform_driver dc_i2c_driver = {
.probe = dc_i2c_probe, .probe = dc_i2c_probe,
.remove = dc_i2c_remove, .remove_new = dc_i2c_remove,
.driver = { .driver = {
.name = "digicolor-i2c", .name = "digicolor-i2c",
.of_match_table = dc_i2c_match, .of_match_table = dc_i2c_match,

View File

@ -236,20 +236,18 @@ out_disable:
return ret; return ret;
} }
static int dln2_i2c_remove(struct platform_device *pdev) static void dln2_i2c_remove(struct platform_device *pdev)
{ {
struct dln2_i2c *dln2 = platform_get_drvdata(pdev); struct dln2_i2c *dln2 = platform_get_drvdata(pdev);
i2c_del_adapter(&dln2->adapter); i2c_del_adapter(&dln2->adapter);
dln2_i2c_enable(dln2, false); dln2_i2c_enable(dln2, false);
return 0;
} }
static struct platform_driver dln2_i2c_driver = { static struct platform_driver dln2_i2c_driver = {
.driver.name = "dln2-i2c", .driver.name = "dln2-i2c",
.probe = dln2_i2c_probe, .probe = dln2_i2c_probe,
.remove = dln2_i2c_remove, .remove_new = dln2_i2c_remove,
}; };
module_platform_driver(dln2_i2c_driver); module_platform_driver(dln2_i2c_driver);

View File

@ -419,14 +419,12 @@ err_clk:
return ret; return ret;
} }
static int em_i2c_remove(struct platform_device *dev) static void em_i2c_remove(struct platform_device *dev)
{ {
struct em_i2c_device *priv = platform_get_drvdata(dev); struct em_i2c_device *priv = platform_get_drvdata(dev);
i2c_del_adapter(&priv->adap); i2c_del_adapter(&priv->adap);
clk_disable_unprepare(priv->sclk); clk_disable_unprepare(priv->sclk);
return 0;
} }
static const struct of_device_id em_i2c_ids[] = { static const struct of_device_id em_i2c_ids[] = {
@ -436,7 +434,7 @@ static const struct of_device_id em_i2c_ids[] = {
static struct platform_driver em_i2c_driver = { static struct platform_driver em_i2c_driver = {
.probe = em_i2c_probe, .probe = em_i2c_probe,
.remove = em_i2c_remove, .remove_new = em_i2c_remove,
.driver = { .driver = {
.name = "em-i2c", .name = "em-i2c",
.of_match_table = em_i2c_ids, .of_match_table = em_i2c_ids,

View File

@ -882,7 +882,7 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
return ret; return ret;
} }
static int exynos5_i2c_remove(struct platform_device *pdev) static void exynos5_i2c_remove(struct platform_device *pdev)
{ {
struct exynos5_i2c *i2c = platform_get_drvdata(pdev); struct exynos5_i2c *i2c = platform_get_drvdata(pdev);
@ -890,8 +890,6 @@ static int exynos5_i2c_remove(struct platform_device *pdev)
clk_unprepare(i2c->clk); clk_unprepare(i2c->clk);
clk_unprepare(i2c->pclk); clk_unprepare(i2c->pclk);
return 0;
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
@ -945,7 +943,7 @@ static const struct dev_pm_ops exynos5_i2c_dev_pm_ops = {
static struct platform_driver exynos5_i2c_driver = { static struct platform_driver exynos5_i2c_driver = {
.probe = exynos5_i2c_probe, .probe = exynos5_i2c_probe,
.remove = exynos5_i2c_remove, .remove_new = exynos5_i2c_remove,
.driver = { .driver = {
.name = "exynos5-hsi2c", .name = "exynos5-hsi2c",
.pm = &exynos5_i2c_dev_pm_ops, .pm = &exynos5_i2c_dev_pm_ops,

View File

@ -475,7 +475,7 @@ static int i2c_gpio_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int i2c_gpio_remove(struct platform_device *pdev) static void i2c_gpio_remove(struct platform_device *pdev)
{ {
struct i2c_gpio_private_data *priv; struct i2c_gpio_private_data *priv;
struct i2c_adapter *adap; struct i2c_adapter *adap;
@ -486,8 +486,6 @@ static int i2c_gpio_remove(struct platform_device *pdev)
adap = &priv->adap; adap = &priv->adap;
i2c_del_adapter(adap); i2c_del_adapter(adap);
return 0;
} }
static const struct of_device_id i2c_gpio_dt_ids[] = { static const struct of_device_id i2c_gpio_dt_ids[] = {
@ -510,7 +508,7 @@ static struct platform_driver i2c_gpio_driver = {
.acpi_match_table = i2c_gpio_acpi_match, .acpi_match_table = i2c_gpio_acpi_match,
}, },
.probe = i2c_gpio_probe, .probe = i2c_gpio_probe,
.remove = i2c_gpio_remove, .remove_new = i2c_gpio_remove,
}; };
static int __init i2c_gpio_init(void) static int __init i2c_gpio_init(void)

View File

@ -577,15 +577,13 @@ static int gxp_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int gxp_i2c_remove(struct platform_device *pdev) static void gxp_i2c_remove(struct platform_device *pdev)
{ {
struct gxp_i2c_drvdata *drvdata = platform_get_drvdata(pdev); struct gxp_i2c_drvdata *drvdata = platform_get_drvdata(pdev);
/* Disable interrupt */ /* Disable interrupt */
regmap_update_bits(i2cg_map, GXP_I2CINTEN, BIT(drvdata->engine), 0); regmap_update_bits(i2cg_map, GXP_I2CINTEN, BIT(drvdata->engine), 0);
i2c_del_adapter(&drvdata->adapter); i2c_del_adapter(&drvdata->adapter);
return 0;
} }
static const struct of_device_id gxp_i2c_of_match[] = { static const struct of_device_id gxp_i2c_of_match[] = {
@ -596,7 +594,7 @@ MODULE_DEVICE_TABLE(of, gxp_i2c_of_match);
static struct platform_driver gxp_i2c_driver = { static struct platform_driver gxp_i2c_driver = {
.probe = gxp_i2c_probe, .probe = gxp_i2c_probe,
.remove = gxp_i2c_remove, .remove_new = gxp_i2c_remove,
.driver = { .driver = {
.name = "gxp-i2c", .name = "gxp-i2c",
.of_match_table = gxp_i2c_of_match, .of_match_table = gxp_i2c_of_match,

View File

@ -435,7 +435,7 @@ err:
return ret; return ret;
} }
static int highlander_i2c_remove(struct platform_device *pdev) static void highlander_i2c_remove(struct platform_device *pdev)
{ {
struct highlander_i2c_dev *dev = platform_get_drvdata(pdev); struct highlander_i2c_dev *dev = platform_get_drvdata(pdev);
@ -446,8 +446,6 @@ static int highlander_i2c_remove(struct platform_device *pdev)
iounmap(dev->base); iounmap(dev->base);
kfree(dev); kfree(dev);
return 0;
} }
static struct platform_driver highlander_i2c_driver = { static struct platform_driver highlander_i2c_driver = {
@ -456,7 +454,7 @@ static struct platform_driver highlander_i2c_driver = {
}, },
.probe = highlander_i2c_probe, .probe = highlander_i2c_probe,
.remove = highlander_i2c_remove, .remove_new = highlander_i2c_remove,
}; };
module_platform_driver(highlander_i2c_driver); module_platform_driver(highlander_i2c_driver);

View File

@ -360,7 +360,11 @@ static int hix5hd2_i2c_xfer(struct i2c_adapter *adap,
pm_runtime_get_sync(priv->dev); pm_runtime_get_sync(priv->dev);
for (i = 0; i < num; i++, msgs++) { for (i = 0; i < num; i++, msgs++) {
stop = (i == num - 1); if ((i == num - 1) || (msgs->flags & I2C_M_STOP))
stop = 1;
else
stop = 0;
ret = hix5hd2_i2c_xfer_msg(priv, msgs, stop); ret = hix5hd2_i2c_xfer_msg(priv, msgs, stop);
if (ret < 0) if (ret < 0)
goto out; goto out;
@ -416,12 +420,11 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)
if (irq < 0) if (irq < 0)
return irq; return irq;
priv->clk = devm_clk_get(&pdev->dev, NULL); priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(priv->clk)) { if (IS_ERR(priv->clk)) {
dev_err(&pdev->dev, "cannot get clock\n"); dev_err(&pdev->dev, "cannot enable clock\n");
return PTR_ERR(priv->clk); return PTR_ERR(priv->clk);
} }
clk_prepare_enable(priv->clk);
strscpy(priv->adap.name, "hix5hd2-i2c", sizeof(priv->adap.name)); strscpy(priv->adap.name, "hix5hd2-i2c", sizeof(priv->adap.name));
priv->dev = &pdev->dev; priv->dev = &pdev->dev;
@ -442,7 +445,7 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)
IRQF_NO_SUSPEND, dev_name(&pdev->dev), priv); IRQF_NO_SUSPEND, dev_name(&pdev->dev), priv);
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", irq); dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", irq);
goto err_clk; return ret;
} }
pm_runtime_set_autosuspend_delay(priv->dev, MSEC_PER_SEC); pm_runtime_set_autosuspend_delay(priv->dev, MSEC_PER_SEC);
@ -459,21 +462,17 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)
err_runtime: err_runtime:
pm_runtime_disable(priv->dev); pm_runtime_disable(priv->dev);
pm_runtime_set_suspended(priv->dev); pm_runtime_set_suspended(priv->dev);
err_clk:
clk_disable_unprepare(priv->clk);
return ret; return ret;
} }
static int hix5hd2_i2c_remove(struct platform_device *pdev) static void hix5hd2_i2c_remove(struct platform_device *pdev)
{ {
struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev); struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev);
i2c_del_adapter(&priv->adap); i2c_del_adapter(&priv->adap);
pm_runtime_disable(priv->dev); pm_runtime_disable(priv->dev);
pm_runtime_set_suspended(priv->dev); pm_runtime_set_suspended(priv->dev);
clk_disable_unprepare(priv->clk);
return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
@ -511,7 +510,7 @@ MODULE_DEVICE_TABLE(of, hix5hd2_i2c_match);
static struct platform_driver hix5hd2_i2c_driver = { static struct platform_driver hix5hd2_i2c_driver = {
.probe = hix5hd2_i2c_probe, .probe = hix5hd2_i2c_probe,
.remove = hix5hd2_i2c_remove, .remove_new = hix5hd2_i2c_remove,
.driver = { .driver = {
.name = "hix5hd2-i2c", .name = "hix5hd2-i2c",
.pm = &hix5hd2_i2c_pm_ops, .pm = &hix5hd2_i2c_pm_ops,

View File

@ -77,6 +77,8 @@
* Alder Lake-M (PCH) 0x54a3 32 hard yes yes yes * Alder Lake-M (PCH) 0x54a3 32 hard yes yes yes
* Raptor Lake-S (PCH) 0x7a23 32 hard yes yes yes * Raptor Lake-S (PCH) 0x7a23 32 hard yes yes yes
* Meteor Lake-P (SOC) 0x7e22 32 hard yes yes yes * Meteor Lake-P (SOC) 0x7e22 32 hard yes yes yes
* Meteor Lake SoC-S (SOC) 0xae22 32 hard yes yes yes
* Meteor Lake PCH-S (PCH) 0x7f23 32 hard yes yes yes
* *
* Features supported by this driver: * Features supported by this driver:
* Software PEC no * Software PEC no
@ -233,6 +235,7 @@
#define PCI_DEVICE_ID_INTEL_RAPTOR_LAKE_S_SMBUS 0x7a23 #define PCI_DEVICE_ID_INTEL_RAPTOR_LAKE_S_SMBUS 0x7a23
#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_S_SMBUS 0x7aa3 #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_S_SMBUS 0x7aa3
#define PCI_DEVICE_ID_INTEL_METEOR_LAKE_P_SMBUS 0x7e22 #define PCI_DEVICE_ID_INTEL_METEOR_LAKE_P_SMBUS 0x7e22
#define PCI_DEVICE_ID_INTEL_METEOR_LAKE_PCH_S_SMBUS 0x7f23
#define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS 0x8c22 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS 0x8c22
#define PCI_DEVICE_ID_INTEL_WILDCATPOINT_SMBUS 0x8ca2 #define PCI_DEVICE_ID_INTEL_WILDCATPOINT_SMBUS 0x8ca2
#define PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS 0x8d22 #define PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS 0x8d22
@ -250,6 +253,7 @@
#define PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS 0xa2a3 #define PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS 0xa2a3
#define PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS 0xa323 #define PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS 0xa323
#define PCI_DEVICE_ID_INTEL_COMETLAKE_V_SMBUS 0xa3a3 #define PCI_DEVICE_ID_INTEL_COMETLAKE_V_SMBUS 0xa3a3
#define PCI_DEVICE_ID_INTEL_METEOR_LAKE_SOC_S_SMBUS 0xae22
struct i801_mux_config { struct i801_mux_config {
char *gpio_chip; char *gpio_chip;
@ -1038,6 +1042,8 @@ static const struct pci_device_id i801_ids[] = {
{ PCI_DEVICE_DATA(INTEL, ALDER_LAKE_M_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, { PCI_DEVICE_DATA(INTEL, ALDER_LAKE_M_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) },
{ PCI_DEVICE_DATA(INTEL, RAPTOR_LAKE_S_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, { PCI_DEVICE_DATA(INTEL, RAPTOR_LAKE_S_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) },
{ PCI_DEVICE_DATA(INTEL, METEOR_LAKE_P_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, { PCI_DEVICE_DATA(INTEL, METEOR_LAKE_P_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) },
{ PCI_DEVICE_DATA(INTEL, METEOR_LAKE_SOC_S_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) },
{ PCI_DEVICE_DATA(INTEL, METEOR_LAKE_PCH_S_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) },
{ 0, } { 0, }
}; };

View File

@ -694,10 +694,8 @@ static int iic_probe(struct platform_device *ofdev)
int ret; int ret;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev)
dev_err(&ofdev->dev, "failed to allocate device data\n");
return -ENOMEM; return -ENOMEM;
}
platform_set_drvdata(ofdev, dev); platform_set_drvdata(ofdev, dev);
@ -769,7 +767,7 @@ error_cleanup:
/* /*
* Cleanup initialized IIC interface * Cleanup initialized IIC interface
*/ */
static int iic_remove(struct platform_device *ofdev) static void iic_remove(struct platform_device *ofdev)
{ {
struct ibm_iic_private *dev = platform_get_drvdata(ofdev); struct ibm_iic_private *dev = platform_get_drvdata(ofdev);
@ -782,8 +780,6 @@ static int iic_remove(struct platform_device *ofdev)
iounmap(dev->vaddr); iounmap(dev->vaddr);
kfree(dev); kfree(dev);
return 0;
} }
static const struct of_device_id ibm_iic_match[] = { static const struct of_device_id ibm_iic_match[] = {
@ -798,7 +794,7 @@ static struct platform_driver ibm_iic_driver = {
.of_match_table = ibm_iic_match, .of_match_table = ibm_iic_match,
}, },
.probe = iic_probe, .probe = iic_probe,
.remove = iic_remove, .remove_new = iic_remove,
}; };
module_platform_driver(ibm_iic_driver); module_platform_driver(ibm_iic_driver);

View File

@ -913,7 +913,7 @@ static unsigned int img_i2c_auto(struct img_i2c *i2c,
static irqreturn_t img_i2c_isr(int irq, void *dev_id) static irqreturn_t img_i2c_isr(int irq, void *dev_id)
{ {
struct img_i2c *i2c = (struct img_i2c *)dev_id; struct img_i2c *i2c = dev_id;
u32 int_status, line_status; u32 int_status, line_status;
/* We handle transaction completion AFTER accessing registers */ /* We handle transaction completion AFTER accessing registers */
unsigned int hret; unsigned int hret;
@ -1413,7 +1413,7 @@ rpm_disable:
return ret; return ret;
} }
static int img_i2c_remove(struct platform_device *dev) static void img_i2c_remove(struct platform_device *dev)
{ {
struct img_i2c *i2c = platform_get_drvdata(dev); struct img_i2c *i2c = platform_get_drvdata(dev);
@ -1421,8 +1421,6 @@ static int img_i2c_remove(struct platform_device *dev)
pm_runtime_disable(&dev->dev); pm_runtime_disable(&dev->dev);
if (!pm_runtime_status_suspended(&dev->dev)) if (!pm_runtime_status_suspended(&dev->dev))
img_i2c_runtime_suspend(&dev->dev); img_i2c_runtime_suspend(&dev->dev);
return 0;
} }
static int img_i2c_runtime_suspend(struct device *dev) static int img_i2c_runtime_suspend(struct device *dev)
@ -1506,7 +1504,7 @@ static struct platform_driver img_scb_i2c_driver = {
.pm = &img_i2c_pm, .pm = &img_i2c_pm,
}, },
.probe = img_i2c_probe, .probe = img_i2c_probe,
.remove = img_i2c_remove, .remove_new = img_i2c_remove,
}; };
module_platform_driver(img_scb_i2c_driver); module_platform_driver(img_scb_i2c_driver);

View File

@ -217,7 +217,7 @@ static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx)
for (prescale = 0; prescale <= 7; prescale++) { for (prescale = 0; prescale <= 7; prescale++) {
clk_cycle = clk_rate / ((1 << prescale) * lpi2c_imx->bitrate) clk_cycle = clk_rate / ((1 << prescale) * lpi2c_imx->bitrate)
- 3 - (filt >> 1); - 3 - (filt >> 1);
clkhi = (clk_cycle + I2C_CLK_RATIO) / (I2C_CLK_RATIO + 1); clkhi = DIV_ROUND_UP(clk_cycle, I2C_CLK_RATIO + 1);
clklo = clk_cycle - clkhi; clklo = clk_cycle - clkhi;
if (clklo < 64) if (clklo < 64)
break; break;
@ -623,7 +623,7 @@ rpm_disable:
return ret; return ret;
} }
static int lpi2c_imx_remove(struct platform_device *pdev) static void lpi2c_imx_remove(struct platform_device *pdev)
{ {
struct lpi2c_imx_struct *lpi2c_imx = platform_get_drvdata(pdev); struct lpi2c_imx_struct *lpi2c_imx = platform_get_drvdata(pdev);
@ -631,8 +631,6 @@ static int lpi2c_imx_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
pm_runtime_dont_use_autosuspend(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev);
return 0;
} }
static int __maybe_unused lpi2c_runtime_suspend(struct device *dev) static int __maybe_unused lpi2c_runtime_suspend(struct device *dev)
@ -669,7 +667,7 @@ static const struct dev_pm_ops lpi2c_pm_ops = {
static struct platform_driver lpi2c_imx_driver = { static struct platform_driver lpi2c_imx_driver = {
.probe = lpi2c_imx_probe, .probe = lpi2c_imx_probe,
.remove = lpi2c_imx_remove, .remove_new = lpi2c_imx_remove,
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.of_match_table = lpi2c_imx_of_match, .of_match_table = lpi2c_imx_of_match,

View File

@ -1561,7 +1561,7 @@ rpm_disable:
return ret; return ret;
} }
static int i2c_imx_remove(struct platform_device *pdev) static void i2c_imx_remove(struct platform_device *pdev)
{ {
struct imx_i2c_struct *i2c_imx = platform_get_drvdata(pdev); struct imx_i2c_struct *i2c_imx = platform_get_drvdata(pdev);
int irq, ret; int irq, ret;
@ -1592,8 +1592,6 @@ static int i2c_imx_remove(struct platform_device *pdev)
pm_runtime_put_noidle(&pdev->dev); pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
return 0;
} }
static int __maybe_unused i2c_imx_runtime_suspend(struct device *dev) static int __maybe_unused i2c_imx_runtime_suspend(struct device *dev)
@ -1624,7 +1622,7 @@ static const struct dev_pm_ops i2c_imx_pm_ops = {
static struct platform_driver i2c_imx_driver = { static struct platform_driver i2c_imx_driver = {
.probe = i2c_imx_probe, .probe = i2c_imx_probe,
.remove = i2c_imx_remove, .remove_new = i2c_imx_remove,
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.pm = &i2c_imx_pm_ops, .pm = &i2c_imx_pm_ops,

View File

@ -388,7 +388,7 @@ static const struct i2c_algorithm iop3xx_i2c_algo = {
.functionality = iop3xx_i2c_func, .functionality = iop3xx_i2c_func,
}; };
static int static void
iop3xx_i2c_remove(struct platform_device *pdev) iop3xx_i2c_remove(struct platform_device *pdev)
{ {
struct i2c_adapter *padapter = platform_get_drvdata(pdev); struct i2c_adapter *padapter = platform_get_drvdata(pdev);
@ -408,8 +408,6 @@ iop3xx_i2c_remove(struct platform_device *pdev)
release_mem_region(res->start, IOP3XX_I2C_IO_SIZE); release_mem_region(res->start, IOP3XX_I2C_IO_SIZE);
kfree(adapter_data); kfree(adapter_data);
kfree(padapter); kfree(padapter);
return 0;
} }
static int static int
@ -529,7 +527,7 @@ MODULE_DEVICE_TABLE(of, i2c_iop3xx_match);
static struct platform_driver iop3xx_i2c_driver = { static struct platform_driver iop3xx_i2c_driver = {
.probe = iop3xx_i2c_probe, .probe = iop3xx_i2c_probe,
.remove = iop3xx_i2c_remove, .remove_new = iop3xx_i2c_remove,
.driver = { .driver = {
.name = "IOP3xx-I2C", .name = "IOP3xx-I2C",
.of_match_table = i2c_iop3xx_match, .of_match_table = i2c_iop3xx_match,

View File

@ -286,14 +286,12 @@ static int smbus_sch_probe(struct platform_device *dev)
return retval; return retval;
} }
static int smbus_sch_remove(struct platform_device *pdev) static void smbus_sch_remove(struct platform_device *pdev)
{ {
if (sch_smba) { if (sch_smba) {
i2c_del_adapter(&sch_adapter); i2c_del_adapter(&sch_adapter);
sch_smba = 0; sch_smba = 0;
} }
return 0;
} }
static struct platform_driver smbus_sch_driver = { static struct platform_driver smbus_sch_driver = {
@ -301,7 +299,7 @@ static struct platform_driver smbus_sch_driver = {
.name = "isch_smbus", .name = "isch_smbus",
}, },
.probe = smbus_sch_probe, .probe = smbus_sch_probe,
.remove = smbus_sch_remove, .remove_new = smbus_sch_remove,
}; };
module_platform_driver(smbus_sch_driver); module_platform_driver(smbus_sch_driver);

View File

@ -845,18 +845,17 @@ err:
return ret; return ret;
} }
static int jz4780_i2c_remove(struct platform_device *pdev) static void jz4780_i2c_remove(struct platform_device *pdev)
{ {
struct jz4780_i2c *i2c = platform_get_drvdata(pdev); struct jz4780_i2c *i2c = platform_get_drvdata(pdev);
clk_disable_unprepare(i2c->clk); clk_disable_unprepare(i2c->clk);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
return 0;
} }
static struct platform_driver jz4780_i2c_driver = { static struct platform_driver jz4780_i2c_driver = {
.probe = jz4780_i2c_probe, .probe = jz4780_i2c_probe,
.remove = jz4780_i2c_remove, .remove_new = jz4780_i2c_remove,
.driver = { .driver = {
.name = "jz4780-i2c", .name = "jz4780-i2c",
.of_match_table = jz4780_i2c_of_matches, .of_match_table = jz4780_i2c_of_matches,

View File

@ -329,7 +329,7 @@ static int kempld_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int kempld_i2c_remove(struct platform_device *pdev) static void kempld_i2c_remove(struct platform_device *pdev)
{ {
struct kempld_i2c_data *i2c = platform_get_drvdata(pdev); struct kempld_i2c_data *i2c = platform_get_drvdata(pdev);
struct kempld_device_data *pld = i2c->pld; struct kempld_device_data *pld = i2c->pld;
@ -348,8 +348,6 @@ static int kempld_i2c_remove(struct platform_device *pdev)
kempld_release_mutex(pld); kempld_release_mutex(pld);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
@ -389,7 +387,7 @@ static struct platform_driver kempld_i2c_driver = {
.name = "kempld-i2c", .name = "kempld-i2c",
}, },
.probe = kempld_i2c_probe, .probe = kempld_i2c_probe,
.remove = kempld_i2c_remove, .remove_new = kempld_i2c_remove,
.suspend = kempld_i2c_suspend, .suspend = kempld_i2c_suspend,
.resume = kempld_i2c_resume, .resume = kempld_i2c_resume,
}; };

View File

@ -365,23 +365,17 @@ static int i2c_lpc2k_probe(struct platform_device *pdev)
init_waitqueue_head(&i2c->wait); init_waitqueue_head(&i2c->wait);
i2c->clk = devm_clk_get(&pdev->dev, NULL); i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(i2c->clk)) { if (IS_ERR(i2c->clk)) {
dev_err(&pdev->dev, "error getting clock\n"); dev_err(&pdev->dev, "failed to enable clock.\n");
return PTR_ERR(i2c->clk); return PTR_ERR(i2c->clk);
} }
ret = clk_prepare_enable(i2c->clk);
if (ret) {
dev_err(&pdev->dev, "unable to enable clock.\n");
return ret;
}
ret = devm_request_irq(&pdev->dev, i2c->irq, i2c_lpc2k_handler, 0, ret = devm_request_irq(&pdev->dev, i2c->irq, i2c_lpc2k_handler, 0,
dev_name(&pdev->dev), i2c); dev_name(&pdev->dev), i2c);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "can't request interrupt.\n"); dev_err(&pdev->dev, "can't request interrupt.\n");
goto fail_clk; return ret;
} }
disable_irq_nosync(i2c->irq); disable_irq_nosync(i2c->irq);
@ -397,8 +391,7 @@ static int i2c_lpc2k_probe(struct platform_device *pdev)
clkrate = clk_get_rate(i2c->clk); clkrate = clk_get_rate(i2c->clk);
if (clkrate == 0) { if (clkrate == 0) {
dev_err(&pdev->dev, "can't get I2C base clock\n"); dev_err(&pdev->dev, "can't get I2C base clock\n");
ret = -EINVAL; return -EINVAL;
goto fail_clk;
} }
/* Setup I2C dividers to generate clock with proper duty cycle */ /* Setup I2C dividers to generate clock with proper duty cycle */
@ -424,25 +417,18 @@ static int i2c_lpc2k_probe(struct platform_device *pdev)
ret = i2c_add_adapter(&i2c->adap); ret = i2c_add_adapter(&i2c->adap);
if (ret < 0) if (ret < 0)
goto fail_clk; return ret;
dev_info(&pdev->dev, "LPC2K I2C adapter\n"); dev_info(&pdev->dev, "LPC2K I2C adapter\n");
return 0; return 0;
fail_clk:
clk_disable_unprepare(i2c->clk);
return ret;
} }
static int i2c_lpc2k_remove(struct platform_device *dev) static void i2c_lpc2k_remove(struct platform_device *dev)
{ {
struct lpc2k_i2c *i2c = platform_get_drvdata(dev); struct lpc2k_i2c *i2c = platform_get_drvdata(dev);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
clk_disable_unprepare(i2c->clk);
return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
@ -483,7 +469,7 @@ MODULE_DEVICE_TABLE(of, lpc2k_i2c_match);
static struct platform_driver i2c_lpc2k_driver = { static struct platform_driver i2c_lpc2k_driver = {
.probe = i2c_lpc2k_probe, .probe = i2c_lpc2k_probe,
.remove = i2c_lpc2k_remove, .remove_new = i2c_lpc2k_remove,
.driver = { .driver = {
.name = "lpc2k-i2c", .name = "lpc2k-i2c",
.pm = I2C_LPC2K_DEV_PM_OPS, .pm = I2C_LPC2K_DEV_PM_OPS,

View File

@ -535,14 +535,12 @@ static int meson_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int meson_i2c_remove(struct platform_device *pdev) static void meson_i2c_remove(struct platform_device *pdev)
{ {
struct meson_i2c *i2c = platform_get_drvdata(pdev); struct meson_i2c *i2c = platform_get_drvdata(pdev);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
clk_disable_unprepare(i2c->clk); clk_disable_unprepare(i2c->clk);
return 0;
} }
static const struct meson_i2c_data i2c_meson6_data = { static const struct meson_i2c_data i2c_meson6_data = {
@ -568,7 +566,7 @@ MODULE_DEVICE_TABLE(of, meson_i2c_match);
static struct platform_driver meson_i2c_driver = { static struct platform_driver meson_i2c_driver = {
.probe = meson_i2c_probe, .probe = meson_i2c_probe,
.remove = meson_i2c_remove, .remove_new = meson_i2c_remove,
.driver = { .driver = {
.name = "meson-i2c", .name = "meson-i2c",
.of_match_table = meson_i2c_match, .of_match_table = meson_i2c_match,

View File

@ -446,14 +446,12 @@ static int mchp_corei2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int mchp_corei2c_remove(struct platform_device *pdev) static void mchp_corei2c_remove(struct platform_device *pdev)
{ {
struct mchp_corei2c_dev *idev = platform_get_drvdata(pdev); struct mchp_corei2c_dev *idev = platform_get_drvdata(pdev);
clk_disable_unprepare(idev->i2c_clk); clk_disable_unprepare(idev->i2c_clk);
i2c_del_adapter(&idev->adapter); i2c_del_adapter(&idev->adapter);
return 0;
} }
static const struct of_device_id mchp_corei2c_of_match[] = { static const struct of_device_id mchp_corei2c_of_match[] = {
@ -465,7 +463,7 @@ MODULE_DEVICE_TABLE(of, mchp_corei2c_of_match);
static struct platform_driver mchp_corei2c_driver = { static struct platform_driver mchp_corei2c_driver = {
.probe = mchp_corei2c_probe, .probe = mchp_corei2c_probe,
.remove = mchp_corei2c_remove, .remove_new = mchp_corei2c_remove,
.driver = { .driver = {
.name = "microchip-corei2c", .name = "microchip-corei2c",
.of_match_table = mchp_corei2c_of_match, .of_match_table = mchp_corei2c_of_match,

View File

@ -2433,7 +2433,7 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int mlxbf_i2c_remove(struct platform_device *pdev) static void mlxbf_i2c_remove(struct platform_device *pdev)
{ {
struct mlxbf_i2c_priv *priv = platform_get_drvdata(pdev); struct mlxbf_i2c_priv *priv = platform_get_drvdata(pdev);
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
@ -2474,13 +2474,11 @@ static int mlxbf_i2c_remove(struct platform_device *pdev)
devm_free_irq(dev, priv->irq, priv); devm_free_irq(dev, priv->irq, priv);
i2c_del_adapter(&priv->adap); i2c_del_adapter(&priv->adap);
return 0;
} }
static struct platform_driver mlxbf_i2c_driver = { static struct platform_driver mlxbf_i2c_driver = {
.probe = mlxbf_i2c_probe, .probe = mlxbf_i2c_probe,
.remove = mlxbf_i2c_remove, .remove_new = mlxbf_i2c_remove,
.driver = { .driver = {
.name = "i2c-mlxbf", .name = "i2c-mlxbf",
.acpi_match_table = ACPI_PTR(mlxbf_i2c_acpi_ids), .acpi_match_table = ACPI_PTR(mlxbf_i2c_acpi_ids),

View File

@ -571,19 +571,17 @@ mlxcpld_i2_probe_failed:
return err; return err;
} }
static int mlxcpld_i2c_remove(struct platform_device *pdev) static void mlxcpld_i2c_remove(struct platform_device *pdev)
{ {
struct mlxcpld_i2c_priv *priv = platform_get_drvdata(pdev); struct mlxcpld_i2c_priv *priv = platform_get_drvdata(pdev);
i2c_del_adapter(&priv->adap); i2c_del_adapter(&priv->adap);
mutex_destroy(&priv->lock); mutex_destroy(&priv->lock);
return 0;
} }
static struct platform_driver mlxcpld_i2c_driver = { static struct platform_driver mlxcpld_i2c_driver = {
.probe = mlxcpld_i2c_probe, .probe = mlxcpld_i2c_probe,
.remove = mlxcpld_i2c_remove, .remove_new = mlxcpld_i2c_remove,
.driver = { .driver = {
.name = MLXCPLD_I2C_DEVICE_NAME, .name = MLXCPLD_I2C_DEVICE_NAME,
}, },

View File

@ -316,9 +316,10 @@ static void mpc_i2c_setup_512x(struct device_node *node,
if (node_ctrl) { if (node_ctrl) {
ctrl = of_iomap(node_ctrl, 0); ctrl = of_iomap(node_ctrl, 0);
if (ctrl) { if (ctrl) {
u64 addr;
/* Interrupt enable bits for i2c-0/1/2: bit 24/26/28 */ /* Interrupt enable bits for i2c-0/1/2: bit 24/26/28 */
pval = of_get_property(node, "reg", NULL); of_property_read_reg(node, 0, &addr, NULL);
idx = (*pval & 0xff) / 0x20; idx = (addr & 0xff) / 0x20;
setbits32(ctrl, 1 << (24 + idx * 2)); setbits32(ctrl, 1 << (24 + idx * 2));
iounmap(ctrl); iounmap(ctrl);
} }
@ -890,15 +891,13 @@ static int fsl_i2c_probe(struct platform_device *op)
return result; return result;
}; };
static int fsl_i2c_remove(struct platform_device *op) static void fsl_i2c_remove(struct platform_device *op)
{ {
struct mpc_i2c *i2c = platform_get_drvdata(op); struct mpc_i2c *i2c = platform_get_drvdata(op);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
clk_disable_unprepare(i2c->clk_per); clk_disable_unprepare(i2c->clk_per);
return 0;
}; };
static int __maybe_unused mpc_i2c_suspend(struct device *dev) static int __maybe_unused mpc_i2c_suspend(struct device *dev)
@ -959,7 +958,7 @@ MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
/* Structure for a device driver */ /* Structure for a device driver */
static struct platform_driver mpc_i2c_driver = { static struct platform_driver mpc_i2c_driver = {
.probe = fsl_i2c_probe, .probe = fsl_i2c_probe,
.remove = fsl_i2c_remove, .remove_new = fsl_i2c_remove,
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.of_match_table = mpc_i2c_of_match, .of_match_table = mpc_i2c_of_match,

View File

@ -1505,15 +1505,13 @@ err_bulk_unprepare:
return ret; return ret;
} }
static int mtk_i2c_remove(struct platform_device *pdev) static void mtk_i2c_remove(struct platform_device *pdev)
{ {
struct mtk_i2c *i2c = platform_get_drvdata(pdev); struct mtk_i2c *i2c = platform_get_drvdata(pdev);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
clk_bulk_unprepare(I2C_MT65XX_CLK_MAX, i2c->clocks); clk_bulk_unprepare(I2C_MT65XX_CLK_MAX, i2c->clocks);
return 0;
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
@ -1555,7 +1553,7 @@ static const struct dev_pm_ops mtk_i2c_pm = {
static struct platform_driver mtk_i2c_driver = { static struct platform_driver mtk_i2c_driver = {
.probe = mtk_i2c_probe, .probe = mtk_i2c_probe,
.remove = mtk_i2c_remove, .remove_new = mtk_i2c_remove,
.driver = { .driver = {
.name = I2C_DRV_NAME, .name = I2C_DRV_NAME,
.pm = &mtk_i2c_pm, .pm = &mtk_i2c_pm,

View File

@ -282,16 +282,11 @@ static int mtk_i2c_probe(struct platform_device *pdev)
if (IS_ERR(i2c->base)) if (IS_ERR(i2c->base))
return PTR_ERR(i2c->base); return PTR_ERR(i2c->base);
i2c->clk = devm_clk_get(&pdev->dev, NULL); i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(i2c->clk)) { if (IS_ERR(i2c->clk)) {
dev_err(&pdev->dev, "no clock defined\n"); dev_err(&pdev->dev, "Failed to enable clock\n");
return PTR_ERR(i2c->clk); return PTR_ERR(i2c->clk);
} }
ret = clk_prepare_enable(i2c->clk);
if (ret) {
dev_err(&pdev->dev, "Unable to enable clock\n");
return ret;
}
i2c->dev = &pdev->dev; i2c->dev = &pdev->dev;
@ -301,8 +296,7 @@ static int mtk_i2c_probe(struct platform_device *pdev)
if (i2c->bus_freq == 0) { if (i2c->bus_freq == 0) {
dev_warn(i2c->dev, "clock-frequency 0 not supported\n"); dev_warn(i2c->dev, "clock-frequency 0 not supported\n");
ret = -EINVAL; return -EINVAL;
goto err_disable_clk;
} }
adap = &i2c->adap; adap = &i2c->adap;
@ -320,31 +314,23 @@ static int mtk_i2c_probe(struct platform_device *pdev)
ret = i2c_add_adapter(adap); ret = i2c_add_adapter(adap);
if (ret < 0) if (ret < 0)
goto err_disable_clk; return ret;
dev_info(&pdev->dev, "clock %u kHz\n", i2c->bus_freq / 1000); dev_info(&pdev->dev, "clock %u kHz\n", i2c->bus_freq / 1000);
return 0; return 0;
err_disable_clk:
clk_disable_unprepare(i2c->clk);
return ret;
} }
static int mtk_i2c_remove(struct platform_device *pdev) static void mtk_i2c_remove(struct platform_device *pdev)
{ {
struct mtk_i2c *i2c = platform_get_drvdata(pdev); struct mtk_i2c *i2c = platform_get_drvdata(pdev);
clk_disable_unprepare(i2c->clk);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
return 0;
} }
static struct platform_driver mtk_i2c_driver = { static struct platform_driver mtk_i2c_driver = {
.probe = mtk_i2c_probe, .probe = mtk_i2c_probe,
.remove = mtk_i2c_remove, .remove_new = mtk_i2c_remove,
.driver = { .driver = {
.name = "i2c-mt7621", .name = "i2c-mt7621",
.of_match_table = i2c_mtk_dt_ids, .of_match_table = i2c_mtk_dt_ids,

View File

@ -1084,7 +1084,7 @@ exit_disable_pm:
return rc; return rc;
} }
static int static void
mv64xxx_i2c_remove(struct platform_device *pd) mv64xxx_i2c_remove(struct platform_device *pd)
{ {
struct mv64xxx_i2c_data *drv_data = platform_get_drvdata(pd); struct mv64xxx_i2c_data *drv_data = platform_get_drvdata(pd);
@ -1094,8 +1094,6 @@ mv64xxx_i2c_remove(struct platform_device *pd)
pm_runtime_disable(&pd->dev); pm_runtime_disable(&pd->dev);
if (!pm_runtime_status_suspended(&pd->dev)) if (!pm_runtime_status_suspended(&pd->dev))
mv64xxx_i2c_runtime_suspend(&pd->dev); mv64xxx_i2c_runtime_suspend(&pd->dev);
return 0;
} }
static const struct dev_pm_ops mv64xxx_i2c_pm_ops = { static const struct dev_pm_ops mv64xxx_i2c_pm_ops = {
@ -1107,7 +1105,7 @@ static const struct dev_pm_ops mv64xxx_i2c_pm_ops = {
static struct platform_driver mv64xxx_i2c_driver = { static struct platform_driver mv64xxx_i2c_driver = {
.probe = mv64xxx_i2c_probe, .probe = mv64xxx_i2c_probe,
.remove = mv64xxx_i2c_remove, .remove_new = mv64xxx_i2c_remove,
.driver = { .driver = {
.name = MV64XXX_I2C_CTLR_NAME, .name = MV64XXX_I2C_CTLR_NAME,
.pm = &mv64xxx_i2c_pm_ops, .pm = &mv64xxx_i2c_pm_ops,

View File

@ -864,7 +864,7 @@ static int mxs_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int mxs_i2c_remove(struct platform_device *pdev) static void mxs_i2c_remove(struct platform_device *pdev)
{ {
struct mxs_i2c_dev *i2c = platform_get_drvdata(pdev); struct mxs_i2c_dev *i2c = platform_get_drvdata(pdev);
@ -874,8 +874,6 @@ static int mxs_i2c_remove(struct platform_device *pdev)
dma_release_channel(i2c->dmach); dma_release_channel(i2c->dmach);
writel(MXS_I2C_CTRL0_SFTRST, i2c->regs + MXS_I2C_CTRL0_SET); writel(MXS_I2C_CTRL0_SFTRST, i2c->regs + MXS_I2C_CTRL0_SET);
return 0;
} }
static struct platform_driver mxs_i2c_driver = { static struct platform_driver mxs_i2c_driver = {
@ -884,7 +882,7 @@ static struct platform_driver mxs_i2c_driver = {
.of_match_table = mxs_i2c_dt_ids, .of_match_table = mxs_i2c_dt_ids,
}, },
.probe = mxs_i2c_probe, .probe = mxs_i2c_probe,
.remove = mxs_i2c_remove, .remove_new = mxs_i2c_remove,
}; };
static int __init mxs_i2c_init(void) static int __init mxs_i2c_init(void)

View File

@ -970,12 +970,10 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
struct i2c_vendor_data *vendor = id->data; struct i2c_vendor_data *vendor = id->data;
u32 max_fifo_threshold = (vendor->fifodepth / 2) - 1; u32 max_fifo_threshold = (vendor->fifodepth / 2) - 1;
dev = devm_kzalloc(&adev->dev, sizeof(struct nmk_i2c_dev), GFP_KERNEL); dev = devm_kzalloc(&adev->dev, sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev)
dev_err(&adev->dev, "cannot allocate memory\n"); return -ENOMEM;
ret = -ENOMEM;
goto err_no_mem;
}
dev->vendor = vendor; dev->vendor = vendor;
dev->adev = adev; dev->adev = adev;
nmk_i2c_of_probe(np, dev); nmk_i2c_of_probe(np, dev);
@ -996,31 +994,20 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
dev->virtbase = devm_ioremap(&adev->dev, adev->res.start, dev->virtbase = devm_ioremap(&adev->dev, adev->res.start,
resource_size(&adev->res)); resource_size(&adev->res));
if (!dev->virtbase) { if (!dev->virtbase)
ret = -ENOMEM; return -ENOMEM;
goto err_no_mem;
}
dev->irq = adev->irq[0]; dev->irq = adev->irq[0];
ret = devm_request_irq(&adev->dev, dev->irq, i2c_irq_handler, 0, ret = devm_request_irq(&adev->dev, dev->irq, i2c_irq_handler, 0,
DRIVER_NAME, dev); DRIVER_NAME, dev);
if (ret) { if (ret)
dev_err(&adev->dev, "cannot claim the irq %d\n", dev->irq); return dev_err_probe(&adev->dev, ret,
goto err_no_mem; "cannot claim the irq %d\n", dev->irq);
}
dev->clk = devm_clk_get(&adev->dev, NULL); dev->clk = devm_clk_get_enabled(&adev->dev, NULL);
if (IS_ERR(dev->clk)) { if (IS_ERR(dev->clk))
dev_err(&adev->dev, "could not get i2c clock\n"); return dev_err_probe(&adev->dev, PTR_ERR(dev->clk),
ret = PTR_ERR(dev->clk); "could enable i2c clock\n");
goto err_no_mem;
}
ret = clk_prepare_enable(dev->clk);
if (ret) {
dev_err(&adev->dev, "can't prepare_enable clock\n");
goto err_no_mem;
}
init_hw(dev); init_hw(dev);
@ -1042,17 +1029,11 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
ret = i2c_add_adapter(adap); ret = i2c_add_adapter(adap);
if (ret) if (ret)
goto err_no_adap; return ret;
pm_runtime_put(&adev->dev); pm_runtime_put(&adev->dev);
return 0; return 0;
err_no_adap:
clk_disable_unprepare(dev->clk);
err_no_mem:
return ret;
} }
static void nmk_i2c_remove(struct amba_device *adev) static void nmk_i2c_remove(struct amba_device *adev)
@ -1066,7 +1047,6 @@ static void nmk_i2c_remove(struct amba_device *adev)
clear_all_interrupts(dev); clear_all_interrupts(dev);
/* disable the controller */ /* disable the controller */
i2c_clr_bit(dev->virtbase + I2C_CR, I2C_CR_PE); i2c_clr_bit(dev->virtbase + I2C_CR, I2C_CR_PE);
clk_disable_unprepare(dev->clk);
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
} }

View File

@ -2361,7 +2361,7 @@ static int npcm_i2c_probe_bus(struct platform_device *pdev)
return 0; return 0;
} }
static int npcm_i2c_remove_bus(struct platform_device *pdev) static void npcm_i2c_remove_bus(struct platform_device *pdev)
{ {
unsigned long lock_flags; unsigned long lock_flags;
struct npcm_i2c *bus = platform_get_drvdata(pdev); struct npcm_i2c *bus = platform_get_drvdata(pdev);
@ -2371,7 +2371,6 @@ static int npcm_i2c_remove_bus(struct platform_device *pdev)
npcm_i2c_disable(bus); npcm_i2c_disable(bus);
spin_unlock_irqrestore(&bus->lock, lock_flags); spin_unlock_irqrestore(&bus->lock, lock_flags);
i2c_del_adapter(&bus->adap); i2c_del_adapter(&bus->adap);
return 0;
} }
static const struct of_device_id npcm_i2c_bus_of_table[] = { static const struct of_device_id npcm_i2c_bus_of_table[] = {
@ -2383,7 +2382,7 @@ MODULE_DEVICE_TABLE(of, npcm_i2c_bus_of_table);
static struct platform_driver npcm_i2c_bus_driver = { static struct platform_driver npcm_i2c_bus_driver = {
.probe = npcm_i2c_probe_bus, .probe = npcm_i2c_probe_bus,
.remove = npcm_i2c_remove_bus, .remove_new = npcm_i2c_remove_bus,
.driver = { .driver = {
.name = "nuvoton-i2c", .name = "nuvoton-i2c",
.of_match_table = npcm_i2c_bus_of_table, .of_match_table = npcm_i2c_bus_of_table,

View File

@ -14,6 +14,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/power_supply.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
@ -261,6 +262,8 @@ MODULE_DEVICE_TABLE(pci, gpu_i2c_ids);
static const struct property_entry ccgx_props[] = { static const struct property_entry ccgx_props[] = {
/* Use FW built for NVIDIA GPU only */ /* Use FW built for NVIDIA GPU only */
PROPERTY_ENTRY_STRING("firmware-name", "nvidia,gpu"), PROPERTY_ENTRY_STRING("firmware-name", "nvidia,gpu"),
/* USB-C doesn't power the system */
PROPERTY_ENTRY_U8("scope", POWER_SUPPLY_SCOPE_DEVICE),
{ } { }
}; };

View File

@ -552,28 +552,20 @@ static int ocores_i2c_of_probe(struct platform_device *pdev,
&clock_frequency); &clock_frequency);
i2c->bus_clock_khz = 100; i2c->bus_clock_khz = 100;
i2c->clk = devm_clk_get(&pdev->dev, NULL); i2c->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
if (IS_ERR(i2c->clk))
return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
"devm_clk_get_optional_enabled failed\n");
if (!IS_ERR(i2c->clk)) {
int ret = clk_prepare_enable(i2c->clk);
if (ret) {
dev_err(&pdev->dev,
"clk_prepare_enable failed: %d\n", ret);
return ret;
}
i2c->ip_clock_khz = clk_get_rate(i2c->clk) / 1000; i2c->ip_clock_khz = clk_get_rate(i2c->clk) / 1000;
if (clock_frequency_present) if (clock_frequency_present)
i2c->bus_clock_khz = clock_frequency / 1000; i2c->bus_clock_khz = clock_frequency / 1000;
}
if (i2c->ip_clock_khz == 0) { if (i2c->ip_clock_khz == 0) {
if (of_property_read_u32(np, "opencores,ip-clock-frequency", if (of_property_read_u32(np, "opencores,ip-clock-frequency",
&val)) { &val)) {
if (!clock_frequency_present) { if (!clock_frequency_present) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Missing required parameter 'opencores,ip-clock-frequency'\n"); "Missing required parameter 'opencores,ip-clock-frequency'\n");
clk_disable_unprepare(i2c->clk);
return -ENODEV; return -ENODEV;
} }
i2c->ip_clock_khz = clock_frequency / 1000; i2c->ip_clock_khz = clock_frequency / 1000;
@ -678,8 +670,7 @@ static int ocores_i2c_probe(struct platform_device *pdev)
default: default:
dev_err(&pdev->dev, "Unsupported I/O width (%d)\n", dev_err(&pdev->dev, "Unsupported I/O width (%d)\n",
i2c->reg_io_width); i2c->reg_io_width);
ret = -EINVAL; return -EINVAL;
goto err_clk;
} }
} }
@ -710,13 +701,13 @@ static int ocores_i2c_probe(struct platform_device *pdev)
pdev->name, i2c); pdev->name, i2c);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Cannot claim IRQ\n"); dev_err(&pdev->dev, "Cannot claim IRQ\n");
goto err_clk; return ret;
} }
} }
ret = ocores_init(&pdev->dev, i2c); ret = ocores_init(&pdev->dev, i2c);
if (ret) if (ret)
goto err_clk; return ret;
/* hook up driver to tree */ /* hook up driver to tree */
platform_set_drvdata(pdev, i2c); platform_set_drvdata(pdev, i2c);
@ -728,7 +719,7 @@ static int ocores_i2c_probe(struct platform_device *pdev)
/* add i2c adapter to i2c tree */ /* add i2c adapter to i2c tree */
ret = i2c_add_adapter(&i2c->adap); ret = i2c_add_adapter(&i2c->adap);
if (ret) if (ret)
goto err_clk; return ret;
/* add in known devices to the bus */ /* add in known devices to the bus */
if (pdata) { if (pdata) {
@ -737,13 +728,9 @@ static int ocores_i2c_probe(struct platform_device *pdev)
} }
return 0; return 0;
err_clk:
clk_disable_unprepare(i2c->clk);
return ret;
} }
static int ocores_i2c_remove(struct platform_device *pdev) static void ocores_i2c_remove(struct platform_device *pdev)
{ {
struct ocores_i2c *i2c = platform_get_drvdata(pdev); struct ocores_i2c *i2c = platform_get_drvdata(pdev);
u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL); u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL);
@ -754,11 +741,6 @@ static int ocores_i2c_remove(struct platform_device *pdev)
/* remove adapter & data */ /* remove adapter & data */
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
if (!IS_ERR(i2c->clk))
clk_disable_unprepare(i2c->clk);
return 0;
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
@ -771,7 +753,6 @@ static int ocores_i2c_suspend(struct device *dev)
ctrl &= ~(OCI2C_CTRL_EN | OCI2C_CTRL_IEN); ctrl &= ~(OCI2C_CTRL_EN | OCI2C_CTRL_IEN);
oc_setreg(i2c, OCI2C_CONTROL, ctrl); oc_setreg(i2c, OCI2C_CONTROL, ctrl);
if (!IS_ERR(i2c->clk))
clk_disable_unprepare(i2c->clk); clk_disable_unprepare(i2c->clk);
return 0; return 0;
} }
@ -779,20 +760,15 @@ static int ocores_i2c_suspend(struct device *dev)
static int ocores_i2c_resume(struct device *dev) static int ocores_i2c_resume(struct device *dev)
{ {
struct ocores_i2c *i2c = dev_get_drvdata(dev); struct ocores_i2c *i2c = dev_get_drvdata(dev);
if (!IS_ERR(i2c->clk)) {
unsigned long rate; unsigned long rate;
int ret = clk_prepare_enable(i2c->clk); int ret;
if (ret) { ret = clk_prepare_enable(i2c->clk);
dev_err(dev, if (ret)
"clk_prepare_enable failed: %d\n", ret); return dev_err_probe(dev, ret, "clk_prepare_enable failed\n");
return ret;
}
rate = clk_get_rate(i2c->clk) / 1000; rate = clk_get_rate(i2c->clk) / 1000;
if (rate) if (rate)
i2c->ip_clock_khz = rate; i2c->ip_clock_khz = rate;
}
return ocores_init(dev, i2c); return ocores_init(dev, i2c);
} }
@ -804,7 +780,7 @@ static SIMPLE_DEV_PM_OPS(ocores_i2c_pm, ocores_i2c_suspend, ocores_i2c_resume);
static struct platform_driver ocores_i2c_driver = { static struct platform_driver ocores_i2c_driver = {
.probe = ocores_i2c_probe, .probe = ocores_i2c_probe,
.remove = ocores_i2c_remove, .remove_new = ocores_i2c_remove,
.driver = { .driver = {
.name = "ocores-i2c", .name = "ocores-i2c",
.of_match_table = ocores_i2c_match, .of_match_table = ocores_i2c_match,

View File

@ -253,12 +253,11 @@ out:
return result; return result;
}; };
static int octeon_i2c_remove(struct platform_device *pdev) static void octeon_i2c_remove(struct platform_device *pdev)
{ {
struct octeon_i2c *i2c = platform_get_drvdata(pdev); struct octeon_i2c *i2c = platform_get_drvdata(pdev);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
return 0;
}; };
static const struct of_device_id octeon_i2c_match[] = { static const struct of_device_id octeon_i2c_match[] = {
@ -270,7 +269,7 @@ MODULE_DEVICE_TABLE(of, octeon_i2c_match);
static struct platform_driver octeon_i2c_driver = { static struct platform_driver octeon_i2c_driver = {
.probe = octeon_i2c_probe, .probe = octeon_i2c_probe,
.remove = octeon_i2c_remove, .remove_new = octeon_i2c_remove,
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.of_match_table = octeon_i2c_match, .of_match_table = octeon_i2c_match,

View File

@ -1519,7 +1519,7 @@ err_disable_pm:
return r; return r;
} }
static int omap_i2c_remove(struct platform_device *pdev) static void omap_i2c_remove(struct platform_device *pdev)
{ {
struct omap_i2c_dev *omap = platform_get_drvdata(pdev); struct omap_i2c_dev *omap = platform_get_drvdata(pdev);
int ret; int ret;
@ -1535,8 +1535,6 @@ static int omap_i2c_remove(struct platform_device *pdev)
pm_runtime_dont_use_autosuspend(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev);
pm_runtime_put_sync(&pdev->dev); pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
return 0;
} }
static int __maybe_unused omap_i2c_runtime_suspend(struct device *dev) static int __maybe_unused omap_i2c_runtime_suspend(struct device *dev)
@ -1588,7 +1586,7 @@ static const struct dev_pm_ops omap_i2c_pm_ops = {
static struct platform_driver omap_i2c_driver = { static struct platform_driver omap_i2c_driver = {
.probe = omap_i2c_probe, .probe = omap_i2c_probe,
.remove = omap_i2c_remove, .remove_new = omap_i2c_remove,
.driver = { .driver = {
.name = "omap_i2c", .name = "omap_i2c",
.pm = &omap_i2c_pm_ops, .pm = &omap_i2c_pm_ops,

View File

@ -232,13 +232,11 @@ static int i2c_opal_probe(struct platform_device *pdev)
return rc; return rc;
} }
static int i2c_opal_remove(struct platform_device *pdev) static void i2c_opal_remove(struct platform_device *pdev)
{ {
struct i2c_adapter *adapter = platform_get_drvdata(pdev); struct i2c_adapter *adapter = platform_get_drvdata(pdev);
i2c_del_adapter(adapter); i2c_del_adapter(adapter);
return 0;
} }
static const struct of_device_id i2c_opal_of_match[] = { static const struct of_device_id i2c_opal_of_match[] = {
@ -251,7 +249,7 @@ MODULE_DEVICE_TABLE(of, i2c_opal_of_match);
static struct platform_driver i2c_opal_driver = { static struct platform_driver i2c_opal_driver = {
.probe = i2c_opal_probe, .probe = i2c_opal_probe,
.remove = i2c_opal_remove, .remove_new = i2c_opal_remove,
.driver = { .driver = {
.name = "i2c-opal", .name = "i2c-opal",
.of_match_table = i2c_opal_of_match, .of_match_table = i2c_opal_of_match,

View File

@ -461,21 +461,16 @@ static int owl_i2c_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
i2c_dev->clk = devm_clk_get(dev, NULL); i2c_dev->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(i2c_dev->clk)) { if (IS_ERR(i2c_dev->clk)) {
dev_err(dev, "failed to get clock\n"); dev_err(dev, "failed to enable clock\n");
return PTR_ERR(i2c_dev->clk); return PTR_ERR(i2c_dev->clk);
} }
ret = clk_prepare_enable(i2c_dev->clk);
if (ret)
return ret;
i2c_dev->clk_rate = clk_get_rate(i2c_dev->clk); i2c_dev->clk_rate = clk_get_rate(i2c_dev->clk);
if (!i2c_dev->clk_rate) { if (!i2c_dev->clk_rate) {
dev_err(dev, "input clock rate should not be zero\n"); dev_err(dev, "input clock rate should not be zero\n");
ret = -EINVAL; return -EINVAL;
goto disable_clk;
} }
init_completion(&i2c_dev->msg_complete); init_completion(&i2c_dev->msg_complete);
@ -496,15 +491,10 @@ static int owl_i2c_probe(struct platform_device *pdev)
i2c_dev); i2c_dev);
if (ret) { if (ret) {
dev_err(dev, "failed to request irq %d\n", irq); dev_err(dev, "failed to request irq %d\n", irq);
goto disable_clk; return ret;
} }
return i2c_add_adapter(&i2c_dev->adap); return i2c_add_adapter(&i2c_dev->adap);
disable_clk:
clk_disable_unprepare(i2c_dev->clk);
return ret;
} }
static const struct of_device_id owl_i2c_of_match[] = { static const struct of_device_id owl_i2c_of_match[] = {

View File

@ -66,22 +66,18 @@ static int pasemi_platform_i2c_probe(struct platform_device *pdev)
if (of_property_read_u32(dev->of_node, "clock-frequency", &frequency)) if (of_property_read_u32(dev->of_node, "clock-frequency", &frequency))
frequency = I2C_MAX_STANDARD_MODE_FREQ; frequency = I2C_MAX_STANDARD_MODE_FREQ;
data->clk_ref = devm_clk_get(dev, NULL); data->clk_ref = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(data->clk_ref)) if (IS_ERR(data->clk_ref))
return PTR_ERR(data->clk_ref); return PTR_ERR(data->clk_ref);
error = clk_prepare_enable(data->clk_ref);
if (error)
return error;
error = pasemi_platform_i2c_calc_clk_div(data, frequency); error = pasemi_platform_i2c_calc_clk_div(data, frequency);
if (error) if (error)
goto out_clk_disable; return error;
smbus->adapter.dev.of_node = pdev->dev.of_node; smbus->adapter.dev.of_node = pdev->dev.of_node;
error = pasemi_i2c_common_probe(smbus); error = pasemi_i2c_common_probe(smbus);
if (error) if (error)
goto out_clk_disable; return error;
irq_num = platform_get_irq(pdev, 0); irq_num = platform_get_irq(pdev, 0);
error = devm_request_irq(smbus->dev, irq_num, pasemi_irq_handler, 0, "pasemi_apple_i2c", (void *)smbus); error = devm_request_irq(smbus->dev, irq_num, pasemi_irq_handler, 0, "pasemi_apple_i2c", (void *)smbus);
@ -91,20 +87,9 @@ static int pasemi_platform_i2c_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, data); platform_set_drvdata(pdev, data);
return 0; return 0;
out_clk_disable:
clk_disable_unprepare(data->clk_ref);
return error;
} }
static int pasemi_platform_i2c_remove(struct platform_device *pdev) static void pasemi_platform_i2c_remove(struct platform_device *pdev) { }
{
struct pasemi_platform_i2c_data *data = platform_get_drvdata(pdev);
clk_disable_unprepare(data->clk_ref);
return 0;
}
static const struct of_device_id pasemi_platform_i2c_of_match[] = { static const struct of_device_id pasemi_platform_i2c_of_match[] = {
{ .compatible = "apple,t8103-i2c" }, { .compatible = "apple,t8103-i2c" },
@ -119,7 +104,7 @@ static struct platform_driver pasemi_platform_i2c_driver = {
.of_match_table = pasemi_platform_i2c_of_match, .of_match_table = pasemi_platform_i2c_of_match,
}, },
.probe = pasemi_platform_i2c_probe, .probe = pasemi_platform_i2c_probe,
.remove = pasemi_platform_i2c_remove, .remove_new = pasemi_platform_i2c_remove,
}; };
module_platform_driver(pasemi_platform_i2c_driver); module_platform_driver(pasemi_platform_i2c_driver);

View File

@ -221,13 +221,11 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int i2c_pca_pf_remove(struct platform_device *pdev) static void i2c_pca_pf_remove(struct platform_device *pdev)
{ {
struct i2c_pca_pf_data *i2c = platform_get_drvdata(pdev); struct i2c_pca_pf_data *i2c = platform_get_drvdata(pdev);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
return 0;
} }
#ifdef CONFIG_OF #ifdef CONFIG_OF
@ -241,7 +239,7 @@ MODULE_DEVICE_TABLE(of, i2c_pca_of_match_table);
static struct platform_driver i2c_pca_pf_driver = { static struct platform_driver i2c_pca_pf_driver = {
.probe = i2c_pca_pf_probe, .probe = i2c_pca_pf_probe,
.remove = i2c_pca_pf_remove, .remove_new = i2c_pca_pf_remove,
.driver = { .driver = {
.name = "i2c-pca-platform", .name = "i2c-pca-platform",
.of_match_table = of_match_ptr(i2c_pca_of_match_table), .of_match_table = of_match_ptr(i2c_pca_of_match_table),

View File

@ -743,14 +743,12 @@ out_clock:
return ret; return ret;
} }
static int i2c_pnx_remove(struct platform_device *pdev) static void i2c_pnx_remove(struct platform_device *pdev)
{ {
struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev); struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
i2c_del_adapter(&alg_data->adapter); i2c_del_adapter(&alg_data->adapter);
clk_disable_unprepare(alg_data->clk); clk_disable_unprepare(alg_data->clk);
return 0;
} }
#ifdef CONFIG_OF #ifdef CONFIG_OF
@ -768,7 +766,7 @@ static struct platform_driver i2c_pnx_driver = {
.pm = PNX_I2C_PM, .pm = PNX_I2C_PM,
}, },
.probe = i2c_pnx_probe, .probe = i2c_pnx_probe,
.remove = i2c_pnx_remove, .remove_new = i2c_pnx_remove,
}; };
static int __init i2c_adap_pnx_init(void) static int __init i2c_adap_pnx_init(void)

View File

@ -188,14 +188,12 @@ static const struct i2c_adapter_quirks i2c_powermac_quirks = {
.max_num_msgs = 1, .max_num_msgs = 1,
}; };
static int i2c_powermac_remove(struct platform_device *dev) static void i2c_powermac_remove(struct platform_device *dev)
{ {
struct i2c_adapter *adapter = platform_get_drvdata(dev); struct i2c_adapter *adapter = platform_get_drvdata(dev);
i2c_del_adapter(adapter); i2c_del_adapter(adapter);
memset(adapter, 0, sizeof(*adapter)); memset(adapter, 0, sizeof(*adapter));
return 0;
} }
static u32 i2c_powermac_get_addr(struct i2c_adapter *adap, static u32 i2c_powermac_get_addr(struct i2c_adapter *adap,
@ -439,7 +437,7 @@ static int i2c_powermac_probe(struct platform_device *dev)
static struct platform_driver i2c_powermac_driver = { static struct platform_driver i2c_powermac_driver = {
.probe = i2c_powermac_probe, .probe = i2c_powermac_probe,
.remove = i2c_powermac_remove, .remove_new = i2c_powermac_remove,
.driver = { .driver = {
.name = "i2c-powermac", .name = "i2c-powermac",
.bus = &platform_bus_type, .bus = &platform_bus_type,

View File

@ -1482,15 +1482,13 @@ ereqirq:
return ret; return ret;
} }
static int i2c_pxa_remove(struct platform_device *dev) static void i2c_pxa_remove(struct platform_device *dev)
{ {
struct pxa_i2c *i2c = platform_get_drvdata(dev); struct pxa_i2c *i2c = platform_get_drvdata(dev);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
clk_disable_unprepare(i2c->clk); clk_disable_unprepare(i2c->clk);
return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
@ -1525,7 +1523,7 @@ static const struct dev_pm_ops i2c_pxa_dev_pm_ops = {
static struct platform_driver i2c_pxa_driver = { static struct platform_driver i2c_pxa_driver = {
.probe = i2c_pxa_probe, .probe = i2c_pxa_probe,
.remove = i2c_pxa_remove, .remove_new = i2c_pxa_remove,
.driver = { .driver = {
.name = "pxa2xx-i2c", .name = "pxa2xx-i2c",
.pm = I2C_PXA_DEV_PM_OPS, .pm = I2C_PXA_DEV_PM_OPS,

View File

@ -581,8 +581,7 @@ static int cci_probe(struct platform_device *pdev)
/* Memory */ /* Memory */
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); cci->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
cci->base = devm_ioremap_resource(dev, r);
if (IS_ERR(cci->base)) if (IS_ERR(cci->base))
return PTR_ERR(cci->base); return PTR_ERR(cci->base);
@ -675,7 +674,7 @@ disable_clocks:
return ret; return ret;
} }
static int cci_remove(struct platform_device *pdev) static void cci_remove(struct platform_device *pdev)
{ {
struct cci *cci = platform_get_drvdata(pdev); struct cci *cci = platform_get_drvdata(pdev);
int i; int i;
@ -691,8 +690,6 @@ static int cci_remove(struct platform_device *pdev)
disable_irq(cci->irq); disable_irq(cci->irq);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev); pm_runtime_set_suspended(&pdev->dev);
return 0;
} }
static const struct cci_data cci_v1_data = { static const struct cci_data cci_v1_data = {
@ -829,7 +826,7 @@ MODULE_DEVICE_TABLE(of, cci_dt_match);
static struct platform_driver qcom_cci_driver = { static struct platform_driver qcom_cci_driver = {
.probe = cci_probe, .probe = cci_probe,
.remove = cci_remove, .remove_new = cci_remove,
.driver = { .driver = {
.name = "i2c-qcom-cci", .name = "i2c-qcom-cci",
.of_match_table = cci_dt_match, .of_match_table = cci_dt_match,

View File

@ -936,14 +936,13 @@ err_dma:
return ret; return ret;
} }
static int geni_i2c_remove(struct platform_device *pdev) static void geni_i2c_remove(struct platform_device *pdev)
{ {
struct geni_i2c_dev *gi2c = platform_get_drvdata(pdev); struct geni_i2c_dev *gi2c = platform_get_drvdata(pdev);
i2c_del_adapter(&gi2c->adap); i2c_del_adapter(&gi2c->adap);
release_gpi_dma(gi2c); release_gpi_dma(gi2c);
pm_runtime_disable(gi2c->se.dev); pm_runtime_disable(gi2c->se.dev);
return 0;
} }
static void geni_i2c_shutdown(struct platform_device *pdev) static void geni_i2c_shutdown(struct platform_device *pdev)
@ -1041,7 +1040,7 @@ MODULE_DEVICE_TABLE(of, geni_i2c_dt_match);
static struct platform_driver geni_i2c_driver = { static struct platform_driver geni_i2c_driver = {
.probe = geni_i2c_probe, .probe = geni_i2c_probe,
.remove = geni_i2c_remove, .remove_new = geni_i2c_remove,
.shutdown = geni_i2c_shutdown, .shutdown = geni_i2c_shutdown,
.driver = { .driver = {
.name = "geni_i2c", .name = "geni_i2c",

View File

@ -1911,7 +1911,7 @@ fail_dma:
return ret; return ret;
} }
static int qup_i2c_remove(struct platform_device *pdev) static void qup_i2c_remove(struct platform_device *pdev)
{ {
struct qup_i2c_dev *qup = platform_get_drvdata(pdev); struct qup_i2c_dev *qup = platform_get_drvdata(pdev);
@ -1925,7 +1925,6 @@ static int qup_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(&qup->adap); i2c_del_adapter(&qup->adap);
pm_runtime_disable(qup->dev); pm_runtime_disable(qup->dev);
pm_runtime_set_suspended(qup->dev); pm_runtime_set_suspended(qup->dev);
return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
@ -1985,7 +1984,7 @@ MODULE_DEVICE_TABLE(of, qup_i2c_dt_match);
static struct platform_driver qup_i2c_driver = { static struct platform_driver qup_i2c_driver = {
.probe = qup_i2c_probe, .probe = qup_i2c_probe,
.remove = qup_i2c_remove, .remove_new = qup_i2c_remove,
.driver = { .driver = {
.name = "i2c_qup", .name = "i2c_qup",
.pm = &qup_i2c_qup_pm_ops, .pm = &qup_i2c_qup_pm_ops,

View File

@ -1155,7 +1155,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
return ret; return ret;
} }
static int rcar_i2c_remove(struct platform_device *pdev) static void rcar_i2c_remove(struct platform_device *pdev)
{ {
struct rcar_i2c_priv *priv = platform_get_drvdata(pdev); struct rcar_i2c_priv *priv = platform_get_drvdata(pdev);
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
@ -1167,8 +1167,6 @@ static int rcar_i2c_remove(struct platform_device *pdev)
if (priv->flags & ID_P_PM_BLOCKED) if (priv->flags & ID_P_PM_BLOCKED)
pm_runtime_put(dev); pm_runtime_put(dev);
pm_runtime_disable(dev); pm_runtime_disable(dev);
return 0;
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
@ -1204,7 +1202,7 @@ static struct platform_driver rcar_i2c_driver = {
.pm = DEV_PM_OPS, .pm = DEV_PM_OPS,
}, },
.probe = rcar_i2c_probe, .probe = rcar_i2c_probe,
.remove = rcar_i2c_remove, .remove_new = rcar_i2c_remove,
}; };
module_platform_driver(rcar_i2c_driver); module_platform_driver(rcar_i2c_driver);

View File

@ -477,7 +477,7 @@ out:
return ret; return ret;
} }
static int riic_i2c_remove(struct platform_device *pdev) static void riic_i2c_remove(struct platform_device *pdev)
{ {
struct riic_dev *riic = platform_get_drvdata(pdev); struct riic_dev *riic = platform_get_drvdata(pdev);
@ -486,8 +486,6 @@ static int riic_i2c_remove(struct platform_device *pdev)
pm_runtime_put(&pdev->dev); pm_runtime_put(&pdev->dev);
i2c_del_adapter(&riic->adapter); i2c_del_adapter(&riic->adapter);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
return 0;
} }
static const struct of_device_id riic_i2c_dt_ids[] = { static const struct of_device_id riic_i2c_dt_ids[] = {
@ -497,7 +495,7 @@ static const struct of_device_id riic_i2c_dt_ids[] = {
static struct platform_driver riic_i2c_driver = { static struct platform_driver riic_i2c_driver = {
.probe = riic_i2c_probe, .probe = riic_i2c_probe,
.remove = riic_i2c_remove, .remove_new = riic_i2c_remove,
.driver = { .driver = {
.name = "i2c-riic", .name = "i2c-riic",
.of_match_table = riic_i2c_dt_ids, .of_match_table = riic_i2c_dt_ids,

View File

@ -1372,7 +1372,7 @@ err_clk:
return ret; return ret;
} }
static int rk3x_i2c_remove(struct platform_device *pdev) static void rk3x_i2c_remove(struct platform_device *pdev)
{ {
struct rk3x_i2c *i2c = platform_get_drvdata(pdev); struct rk3x_i2c *i2c = platform_get_drvdata(pdev);
@ -1381,15 +1381,13 @@ static int rk3x_i2c_remove(struct platform_device *pdev)
clk_notifier_unregister(i2c->clk, &i2c->clk_rate_nb); clk_notifier_unregister(i2c->clk, &i2c->clk_rate_nb);
clk_unprepare(i2c->pclk); clk_unprepare(i2c->pclk);
clk_unprepare(i2c->clk); clk_unprepare(i2c->clk);
return 0;
} }
static SIMPLE_DEV_PM_OPS(rk3x_i2c_pm_ops, NULL, rk3x_i2c_resume); static SIMPLE_DEV_PM_OPS(rk3x_i2c_pm_ops, NULL, rk3x_i2c_resume);
static struct platform_driver rk3x_i2c_driver = { static struct platform_driver rk3x_i2c_driver = {
.probe = rk3x_i2c_probe, .probe = rk3x_i2c_probe,
.remove = rk3x_i2c_remove, .remove_new = rk3x_i2c_remove,
.driver = { .driver = {
.name = "rk3x-i2c", .name = "rk3x-i2c",
.of_match_table = rk3x_i2c_match, .of_match_table = rk3x_i2c_match,

View File

@ -50,9 +50,6 @@
#define IICB0MDSC BIT(7) /* Bus Mode */ #define IICB0MDSC BIT(7) /* Bus Mode */
#define IICB0SLSE BIT(1) /* Start condition output */ #define IICB0SLSE BIT(1) /* Start condition output */
#define bit_setl(addr, val) writel(readl(addr) | (val), (addr))
#define bit_clrl(addr, val) writel(readl(addr) & ~(val), (addr))
struct rzv2m_i2c_priv { struct rzv2m_i2c_priv {
void __iomem *base; void __iomem *base;
struct i2c_adapter adap; struct i2c_adapter adap;
@ -78,6 +75,16 @@ static const struct bitrate_config bitrate_configs[] = {
[RZV2M_I2C_400K] = { 52, 900 }, [RZV2M_I2C_400K] = { 52, 900 },
}; };
static inline void bit_setl(void __iomem *addr, u32 val)
{
writel(readl(addr) | val, addr);
}
static inline void bit_clrl(void __iomem *addr, u32 val)
{
writel(readl(addr) & ~val, addr);
}
static irqreturn_t rzv2m_i2c_tia_irq_handler(int this_irq, void *dev_id) static irqreturn_t rzv2m_i2c_tia_irq_handler(int this_irq, void *dev_id)
{ {
struct rzv2m_i2c_priv *priv = dev_id; struct rzv2m_i2c_priv *priv = dev_id;
@ -382,6 +389,20 @@ static u32 rzv2m_i2c_func(struct i2c_adapter *adap)
I2C_FUNC_10BIT_ADDR; I2C_FUNC_10BIT_ADDR;
} }
static int rzv2m_i2c_disable(struct device *dev, struct rzv2m_i2c_priv *priv)
{
int ret;
ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
return ret;
bit_clrl(priv->base + IICB0CTL0, IICB0IICE);
pm_runtime_put(dev);
return 0;
}
static const struct i2c_adapter_quirks rzv2m_i2c_quirks = { static const struct i2c_adapter_quirks rzv2m_i2c_quirks = {
.flags = I2C_AQ_NO_ZERO_LEN, .flags = I2C_AQ_NO_ZERO_LEN,
}; };
@ -454,37 +475,29 @@ static int rzv2m_i2c_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
ret = i2c_add_numbered_adapter(adap); ret = i2c_add_numbered_adapter(adap);
if (ret < 0) if (ret < 0) {
rzv2m_i2c_disable(dev, priv);
pm_runtime_disable(dev); pm_runtime_disable(dev);
}
return ret; return ret;
} }
static int rzv2m_i2c_remove(struct platform_device *pdev) static void rzv2m_i2c_remove(struct platform_device *pdev)
{ {
struct rzv2m_i2c_priv *priv = platform_get_drvdata(pdev); struct rzv2m_i2c_priv *priv = platform_get_drvdata(pdev);
struct device *dev = priv->adap.dev.parent; struct device *dev = priv->adap.dev.parent;
i2c_del_adapter(&priv->adap); i2c_del_adapter(&priv->adap);
bit_clrl(priv->base + IICB0CTL0, IICB0IICE); rzv2m_i2c_disable(dev, priv);
pm_runtime_disable(dev); pm_runtime_disable(dev);
return 0;
} }
static int rzv2m_i2c_suspend(struct device *dev) static int rzv2m_i2c_suspend(struct device *dev)
{ {
struct rzv2m_i2c_priv *priv = dev_get_drvdata(dev); struct rzv2m_i2c_priv *priv = dev_get_drvdata(dev);
int ret;
ret = pm_runtime_resume_and_get(dev); return rzv2m_i2c_disable(dev, priv);
if (ret < 0)
return ret;
bit_clrl(priv->base + IICB0CTL0, IICB0IICE);
pm_runtime_put(dev);
return 0;
} }
static int rzv2m_i2c_resume(struct device *dev) static int rzv2m_i2c_resume(struct device *dev)
@ -523,7 +536,7 @@ static struct platform_driver rzv2m_i2c_driver = {
.pm = pm_sleep_ptr(&rzv2m_i2c_pm_ops), .pm = pm_sleep_ptr(&rzv2m_i2c_pm_ops),
}, },
.probe = rzv2m_i2c_probe, .probe = rzv2m_i2c_probe,
.remove = rzv2m_i2c_remove, .remove_new = rzv2m_i2c_remove,
}; };
module_platform_driver(rzv2m_i2c_driver); module_platform_driver(rzv2m_i2c_driver);

View File

@ -1114,7 +1114,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int s3c24xx_i2c_remove(struct platform_device *pdev) static void s3c24xx_i2c_remove(struct platform_device *pdev)
{ {
struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
@ -1123,8 +1123,6 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
return 0;
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
@ -1172,7 +1170,7 @@ static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
static struct platform_driver s3c24xx_i2c_driver = { static struct platform_driver s3c24xx_i2c_driver = {
.probe = s3c24xx_i2c_probe, .probe = s3c24xx_i2c_probe,
.remove = s3c24xx_i2c_remove, .remove_new = s3c24xx_i2c_remove,
.id_table = s3c24xx_driver_ids, .id_table = s3c24xx_driver_ids,
.driver = { .driver = {
.name = "s3c-i2c", .name = "s3c-i2c",

View File

@ -404,19 +404,17 @@ err:
return ret; return ret;
} }
static int smbus_cmi_remove(struct platform_device *device) static void smbus_cmi_remove(struct platform_device *device)
{ {
struct acpi_smbus_cmi *smbus_cmi = platform_get_drvdata(device); struct acpi_smbus_cmi *smbus_cmi = platform_get_drvdata(device);
i2c_del_adapter(&smbus_cmi->adapter); i2c_del_adapter(&smbus_cmi->adapter);
kfree(smbus_cmi); kfree(smbus_cmi);
return 0;
} }
static struct platform_driver smbus_cmi_driver = { static struct platform_driver smbus_cmi_driver = {
.probe = smbus_cmi_probe, .probe = smbus_cmi_probe,
.remove = smbus_cmi_remove, .remove_new = smbus_cmi_remove,
.driver = { .driver = {
.name = "smbus_cmi", .name = "smbus_cmi",
.acpi_match_table = acpi_smbus_cmi_ids, .acpi_match_table = acpi_smbus_cmi_ids,

View File

@ -443,9 +443,8 @@ static int sh7760_i2c_probe(struct platform_device *pdev)
goto out0; goto out0;
} }
id = kzalloc(sizeof(struct cami2c), GFP_KERNEL); id = kzalloc(sizeof(*id), GFP_KERNEL);
if (!id) { if (!id) {
dev_err(&pdev->dev, "no mem for private data\n");
ret = -ENOMEM; ret = -ENOMEM;
goto out0; goto out0;
} }
@ -536,7 +535,7 @@ out0:
return ret; return ret;
} }
static int sh7760_i2c_remove(struct platform_device *pdev) static void sh7760_i2c_remove(struct platform_device *pdev)
{ {
struct cami2c *id = platform_get_drvdata(pdev); struct cami2c *id = platform_get_drvdata(pdev);
@ -546,8 +545,6 @@ static int sh7760_i2c_remove(struct platform_device *pdev)
release_resource(id->ioarea); release_resource(id->ioarea);
kfree(id->ioarea); kfree(id->ioarea);
kfree(id); kfree(id);
return 0;
} }
static struct platform_driver sh7760_i2c_drv = { static struct platform_driver sh7760_i2c_drv = {
@ -555,7 +552,7 @@ static struct platform_driver sh7760_i2c_drv = {
.name = SH7760_I2C_DEVNAME, .name = SH7760_I2C_DEVNAME,
}, },
.probe = sh7760_i2c_probe, .probe = sh7760_i2c_probe,
.remove = sh7760_i2c_remove, .remove_new = sh7760_i2c_remove,
}; };
module_platform_driver(sh7760_i2c_drv); module_platform_driver(sh7760_i2c_drv);

View File

@ -956,14 +956,13 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
return 0; return 0;
} }
static int sh_mobile_i2c_remove(struct platform_device *dev) static void sh_mobile_i2c_remove(struct platform_device *dev)
{ {
struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev); struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev);
i2c_del_adapter(&pd->adap); i2c_del_adapter(&pd->adap);
sh_mobile_i2c_release_dma(pd); sh_mobile_i2c_release_dma(pd);
pm_runtime_disable(&dev->dev); pm_runtime_disable(&dev->dev);
return 0;
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
@ -1000,7 +999,7 @@ static struct platform_driver sh_mobile_i2c_driver = {
.pm = DEV_PM_OPS, .pm = DEV_PM_OPS,
}, },
.probe = sh_mobile_i2c_probe, .probe = sh_mobile_i2c_probe,
.remove = sh_mobile_i2c_remove, .remove_new = sh_mobile_i2c_remove,
}; };
static int __init sh_mobile_i2c_adap_init(void) static int __init sh_mobile_i2c_adap_init(void)

View File

@ -126,7 +126,7 @@ static int simtec_i2c_probe(struct platform_device *dev)
return ret; return ret;
} }
static int simtec_i2c_remove(struct platform_device *dev) static void simtec_i2c_remove(struct platform_device *dev)
{ {
struct simtec_i2c_data *pd = platform_get_drvdata(dev); struct simtec_i2c_data *pd = platform_get_drvdata(dev);
@ -135,8 +135,6 @@ static int simtec_i2c_remove(struct platform_device *dev)
iounmap(pd->reg); iounmap(pd->reg);
release_mem_region(pd->ioarea->start, resource_size(pd->ioarea)); release_mem_region(pd->ioarea->start, resource_size(pd->ioarea));
kfree(pd); kfree(pd);
return 0;
} }
/* device driver */ /* device driver */
@ -146,7 +144,7 @@ static struct platform_driver simtec_i2c_driver = {
.name = "simtec-i2c", .name = "simtec-i2c",
}, },
.probe = simtec_i2c_probe, .probe = simtec_i2c_probe,
.remove = simtec_i2c_remove, .remove_new = simtec_i2c_remove,
}; };
module_platform_driver(simtec_i2c_driver); module_platform_driver(simtec_i2c_driver);

View File

@ -876,13 +876,11 @@ static int st_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int st_i2c_remove(struct platform_device *pdev) static void st_i2c_remove(struct platform_device *pdev)
{ {
struct st_i2c_dev *i2c_dev = platform_get_drvdata(pdev); struct st_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
i2c_del_adapter(&i2c_dev->adap); i2c_del_adapter(&i2c_dev->adap);
return 0;
} }
static const struct of_device_id st_i2c_match[] = { static const struct of_device_id st_i2c_match[] = {
@ -899,7 +897,7 @@ static struct platform_driver st_i2c_driver = {
.pm = pm_sleep_ptr(&st_i2c_pm), .pm = pm_sleep_ptr(&st_i2c_pm),
}, },
.probe = st_i2c_probe, .probe = st_i2c_probe,
.remove = st_i2c_remove, .remove_new = st_i2c_remove,
}; };
module_platform_driver(st_i2c_driver); module_platform_driver(st_i2c_driver);

View File

@ -861,15 +861,13 @@ clk_free:
return ret; return ret;
} }
static int stm32f4_i2c_remove(struct platform_device *pdev) static void stm32f4_i2c_remove(struct platform_device *pdev)
{ {
struct stm32f4_i2c_dev *i2c_dev = platform_get_drvdata(pdev); struct stm32f4_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
i2c_del_adapter(&i2c_dev->adap); i2c_del_adapter(&i2c_dev->adap);
clk_unprepare(i2c_dev->clk); clk_unprepare(i2c_dev->clk);
return 0;
} }
static const struct of_device_id stm32f4_i2c_match[] = { static const struct of_device_id stm32f4_i2c_match[] = {
@ -884,7 +882,7 @@ static struct platform_driver stm32f4_i2c_driver = {
.of_match_table = stm32f4_i2c_match, .of_match_table = stm32f4_i2c_match,
}, },
.probe = stm32f4_i2c_probe, .probe = stm32f4_i2c_probe,
.remove = stm32f4_i2c_remove, .remove_new = stm32f4_i2c_remove,
}; };
module_platform_driver(stm32f4_i2c_driver); module_platform_driver(stm32f4_i2c_driver);

View File

@ -2309,7 +2309,7 @@ clk_free:
return ret; return ret;
} }
static int stm32f7_i2c_remove(struct platform_device *pdev) static void stm32f7_i2c_remove(struct platform_device *pdev)
{ {
struct stm32f7_i2c_dev *i2c_dev = platform_get_drvdata(pdev); struct stm32f7_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
@ -2341,8 +2341,6 @@ static int stm32f7_i2c_remove(struct platform_device *pdev)
stm32f7_i2c_write_fm_plus_bits(i2c_dev, false); stm32f7_i2c_write_fm_plus_bits(i2c_dev, false);
clk_disable_unprepare(i2c_dev->clk); clk_disable_unprepare(i2c_dev->clk);
return 0;
} }
static int __maybe_unused stm32f7_i2c_runtime_suspend(struct device *dev) static int __maybe_unused stm32f7_i2c_runtime_suspend(struct device *dev)
@ -2486,7 +2484,7 @@ static struct platform_driver stm32f7_i2c_driver = {
.pm = &stm32f7_i2c_pm_ops, .pm = &stm32f7_i2c_pm_ops,
}, },
.probe = stm32f7_i2c_probe, .probe = stm32f7_i2c_probe,
.remove = stm32f7_i2c_remove, .remove_new = stm32f7_i2c_remove,
}; };
module_platform_driver(stm32f7_i2c_driver); module_platform_driver(stm32f7_i2c_driver);

View File

@ -239,15 +239,9 @@ static int p2wi_probe(struct platform_device *pdev)
if (irq < 0) if (irq < 0)
return irq; return irq;
p2wi->clk = devm_clk_get(dev, NULL); p2wi->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(p2wi->clk)) { if (IS_ERR(p2wi->clk)) {
ret = PTR_ERR(p2wi->clk); ret = PTR_ERR(p2wi->clk);
dev_err(dev, "failed to retrieve clk: %d\n", ret);
return ret;
}
ret = clk_prepare_enable(p2wi->clk);
if (ret) {
dev_err(dev, "failed to enable clk: %d\n", ret); dev_err(dev, "failed to enable clk: %d\n", ret);
return ret; return ret;
} }
@ -256,15 +250,14 @@ static int p2wi_probe(struct platform_device *pdev)
p2wi->rstc = devm_reset_control_get_exclusive(dev, NULL); p2wi->rstc = devm_reset_control_get_exclusive(dev, NULL);
if (IS_ERR(p2wi->rstc)) { if (IS_ERR(p2wi->rstc)) {
ret = PTR_ERR(p2wi->rstc);
dev_err(dev, "failed to retrieve reset controller: %d\n", ret); dev_err(dev, "failed to retrieve reset controller: %d\n", ret);
goto err_clk_disable; return PTR_ERR(p2wi->rstc);
} }
ret = reset_control_deassert(p2wi->rstc); ret = reset_control_deassert(p2wi->rstc);
if (ret) { if (ret) {
dev_err(dev, "failed to deassert reset line: %d\n", ret); dev_err(dev, "failed to deassert reset line: %d\n", ret);
goto err_clk_disable; return ret;
} }
init_completion(&p2wi->complete); init_completion(&p2wi->complete);
@ -307,26 +300,20 @@ static int p2wi_probe(struct platform_device *pdev)
err_reset_assert: err_reset_assert:
reset_control_assert(p2wi->rstc); reset_control_assert(p2wi->rstc);
err_clk_disable:
clk_disable_unprepare(p2wi->clk);
return ret; return ret;
} }
static int p2wi_remove(struct platform_device *dev) static void p2wi_remove(struct platform_device *dev)
{ {
struct p2wi *p2wi = platform_get_drvdata(dev); struct p2wi *p2wi = platform_get_drvdata(dev);
reset_control_assert(p2wi->rstc); reset_control_assert(p2wi->rstc);
clk_disable_unprepare(p2wi->clk);
i2c_del_adapter(&p2wi->adapter); i2c_del_adapter(&p2wi->adapter);
return 0;
} }
static struct platform_driver p2wi_driver = { static struct platform_driver p2wi_driver = {
.probe = p2wi_probe, .probe = p2wi_probe,
.remove = p2wi_remove, .remove_new = p2wi_remove,
.driver = { .driver = {
.name = "i2c-sunxi-p2wi", .name = "i2c-sunxi-p2wi",
.of_match_table = p2wi_of_match_table, .of_match_table = p2wi_of_match_table,

View File

@ -618,15 +618,13 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int synquacer_i2c_remove(struct platform_device *pdev) static void synquacer_i2c_remove(struct platform_device *pdev)
{ {
struct synquacer_i2c *i2c = platform_get_drvdata(pdev); struct synquacer_i2c *i2c = platform_get_drvdata(pdev);
i2c_del_adapter(&i2c->adapter); i2c_del_adapter(&i2c->adapter);
if (!IS_ERR(i2c->pclk)) if (!IS_ERR(i2c->pclk))
clk_disable_unprepare(i2c->pclk); clk_disable_unprepare(i2c->pclk);
return 0;
}; };
static const struct of_device_id synquacer_i2c_dt_ids[] __maybe_unused = { static const struct of_device_id synquacer_i2c_dt_ids[] __maybe_unused = {
@ -645,7 +643,7 @@ MODULE_DEVICE_TABLE(acpi, synquacer_i2c_acpi_ids);
static struct platform_driver synquacer_i2c_driver = { static struct platform_driver synquacer_i2c_driver = {
.probe = synquacer_i2c_probe, .probe = synquacer_i2c_probe,
.remove = synquacer_i2c_remove, .remove_new = synquacer_i2c_remove,
.driver = { .driver = {
.name = "synquacer_i2c", .name = "synquacer_i2c",
.of_match_table = of_match_ptr(synquacer_i2c_dt_ids), .of_match_table = of_match_ptr(synquacer_i2c_dt_ids),

View File

@ -316,13 +316,11 @@ static int tegra_bpmp_i2c_probe(struct platform_device *pdev)
return i2c_add_adapter(&i2c->adapter); return i2c_add_adapter(&i2c->adapter);
} }
static int tegra_bpmp_i2c_remove(struct platform_device *pdev) static void tegra_bpmp_i2c_remove(struct platform_device *pdev)
{ {
struct tegra_bpmp_i2c *i2c = platform_get_drvdata(pdev); struct tegra_bpmp_i2c *i2c = platform_get_drvdata(pdev);
i2c_del_adapter(&i2c->adapter); i2c_del_adapter(&i2c->adapter);
return 0;
} }
static const struct of_device_id tegra_bpmp_i2c_of_match[] = { static const struct of_device_id tegra_bpmp_i2c_of_match[] = {
@ -337,7 +335,7 @@ static struct platform_driver tegra_bpmp_i2c_driver = {
.of_match_table = tegra_bpmp_i2c_of_match, .of_match_table = tegra_bpmp_i2c_of_match,
}, },
.probe = tegra_bpmp_i2c_probe, .probe = tegra_bpmp_i2c_probe,
.remove = tegra_bpmp_i2c_remove, .remove_new = tegra_bpmp_i2c_remove,
}; };
module_platform_driver(tegra_bpmp_i2c_driver); module_platform_driver(tegra_bpmp_i2c_driver);

View File

@ -249,8 +249,7 @@ struct tegra_i2c_hw_feature {
* @msg_read: indicates that the transfer is a read access * @msg_read: indicates that the transfer is a read access
* @timings: i2c timings information like bus frequency * @timings: i2c timings information like bus frequency
* @multimaster_mode: indicates that I2C controller is in multi-master mode * @multimaster_mode: indicates that I2C controller is in multi-master mode
* @tx_dma_chan: DMA transmit channel * @dma_chan: DMA channel
* @rx_dma_chan: DMA receive channel
* @dma_phys: handle to DMA resources * @dma_phys: handle to DMA resources
* @dma_buf: pointer to allocated DMA buffer * @dma_buf: pointer to allocated DMA buffer
* @dma_buf_size: DMA buffer size * @dma_buf_size: DMA buffer size
@ -283,8 +282,7 @@ struct tegra_i2c_dev {
u8 *msg_buf; u8 *msg_buf;
struct completion dma_complete; struct completion dma_complete;
struct dma_chan *tx_dma_chan; struct dma_chan *dma_chan;
struct dma_chan *rx_dma_chan;
unsigned int dma_buf_size; unsigned int dma_buf_size;
struct device *dma_dev; struct device *dma_dev;
dma_addr_t dma_phys; dma_addr_t dma_phys;
@ -298,6 +296,9 @@ struct tegra_i2c_dev {
bool is_vi; bool is_vi;
}; };
#define IS_DVC(dev) (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && (dev)->is_dvc)
#define IS_VI(dev) (IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) && (dev)->is_vi)
static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val, static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val,
unsigned int reg) unsigned int reg)
{ {
@ -315,9 +316,9 @@ static u32 dvc_readl(struct tegra_i2c_dev *i2c_dev, unsigned int reg)
*/ */
static u32 tegra_i2c_reg_addr(struct tegra_i2c_dev *i2c_dev, unsigned int reg) static u32 tegra_i2c_reg_addr(struct tegra_i2c_dev *i2c_dev, unsigned int reg)
{ {
if (i2c_dev->is_dvc) if (IS_DVC(i2c_dev))
reg += (reg >= I2C_TX_FIFO) ? 0x10 : 0x40; reg += (reg >= I2C_TX_FIFO) ? 0x10 : 0x40;
else if (i2c_dev->is_vi) else if (IS_VI(i2c_dev))
reg = 0xc00 + (reg << 2); reg = 0xc00 + (reg << 2);
return reg; return reg;
@ -330,7 +331,7 @@ static void i2c_writel(struct tegra_i2c_dev *i2c_dev, u32 val, unsigned int reg)
/* read back register to make sure that register writes completed */ /* read back register to make sure that register writes completed */
if (reg != I2C_TX_FIFO) if (reg != I2C_TX_FIFO)
readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg)); readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg));
else if (i2c_dev->is_vi) else if (IS_VI(i2c_dev))
readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, I2C_INT_STATUS)); readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, I2C_INT_STATUS));
} }
@ -393,16 +394,14 @@ static int tegra_i2c_dma_submit(struct tegra_i2c_dev *i2c_dev, size_t len)
{ {
struct dma_async_tx_descriptor *dma_desc; struct dma_async_tx_descriptor *dma_desc;
enum dma_transfer_direction dir; enum dma_transfer_direction dir;
struct dma_chan *chan;
dev_dbg(i2c_dev->dev, "starting DMA for length: %zu\n", len); dev_dbg(i2c_dev->dev, "starting DMA for length: %zu\n", len);
reinit_completion(&i2c_dev->dma_complete); reinit_completion(&i2c_dev->dma_complete);
dir = i2c_dev->msg_read ? DMA_DEV_TO_MEM : DMA_MEM_TO_DEV; dir = i2c_dev->msg_read ? DMA_DEV_TO_MEM : DMA_MEM_TO_DEV;
chan = i2c_dev->msg_read ? i2c_dev->rx_dma_chan : i2c_dev->tx_dma_chan;
dma_desc = dmaengine_prep_slave_single(chan, i2c_dev->dma_phys, dma_desc = dmaengine_prep_slave_single(i2c_dev->dma_chan, i2c_dev->dma_phys,
len, dir, DMA_PREP_INTERRUPT | len, dir, DMA_PREP_INTERRUPT |
DMA_CTRL_ACK); DMA_CTRL_ACK);
if (!dma_desc) { if (!dma_desc) {
@ -415,7 +414,7 @@ static int tegra_i2c_dma_submit(struct tegra_i2c_dev *i2c_dev, size_t len)
dma_desc->callback_param = i2c_dev; dma_desc->callback_param = i2c_dev;
dmaengine_submit(dma_desc); dmaengine_submit(dma_desc);
dma_async_issue_pending(chan); dma_async_issue_pending(i2c_dev->dma_chan);
return 0; return 0;
} }
@ -428,25 +427,19 @@ static void tegra_i2c_release_dma(struct tegra_i2c_dev *i2c_dev)
i2c_dev->dma_buf = NULL; i2c_dev->dma_buf = NULL;
} }
if (i2c_dev->tx_dma_chan) { if (i2c_dev->dma_chan) {
dma_release_channel(i2c_dev->tx_dma_chan); dma_release_channel(i2c_dev->dma_chan);
i2c_dev->tx_dma_chan = NULL; i2c_dev->dma_chan = NULL;
}
if (i2c_dev->rx_dma_chan) {
dma_release_channel(i2c_dev->rx_dma_chan);
i2c_dev->rx_dma_chan = NULL;
} }
} }
static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev) static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev)
{ {
struct dma_chan *chan;
dma_addr_t dma_phys; dma_addr_t dma_phys;
u32 *dma_buf; u32 *dma_buf;
int err; int err;
if (i2c_dev->is_vi) if (IS_VI(i2c_dev))
return 0; return 0;
if (!i2c_dev->hw->has_apb_dma) { if (!i2c_dev->hw->has_apb_dma) {
@ -459,25 +452,18 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev)
return 0; return 0;
} }
chan = dma_request_chan(i2c_dev->dev, "rx"); /*
if (IS_ERR(chan)) { * The same channel will be used for both RX and TX.
err = PTR_ERR(chan); * Keeping the name as "tx" for backward compatibility
* with existing devicetrees.
*/
i2c_dev->dma_chan = dma_request_chan(i2c_dev->dev, "tx");
if (IS_ERR(i2c_dev->dma_chan)) {
err = PTR_ERR(i2c_dev->dma_chan);
goto err_out; goto err_out;
} }
i2c_dev->rx_dma_chan = chan; i2c_dev->dma_dev = i2c_dev->dma_chan->device->dev;
chan = dma_request_chan(i2c_dev->dev, "tx");
if (IS_ERR(chan)) {
err = PTR_ERR(chan);
goto err_out;
}
i2c_dev->tx_dma_chan = chan;
WARN_ON(i2c_dev->tx_dma_chan->device != i2c_dev->rx_dma_chan->device);
i2c_dev->dma_dev = chan->device->dev;
i2c_dev->dma_buf_size = i2c_dev->hw->quirks->max_write_len + i2c_dev->dma_buf_size = i2c_dev->hw->quirks->max_write_len +
I2C_PACKET_HEADER_SIZE; I2C_PACKET_HEADER_SIZE;
@ -639,7 +625,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
WARN_ON_ONCE(err); WARN_ON_ONCE(err);
if (i2c_dev->is_dvc) if (IS_DVC(i2c_dev))
tegra_dvc_init(i2c_dev); tegra_dvc_init(i2c_dev);
val = I2C_CNFG_NEW_MASTER_FSM | I2C_CNFG_PACKET_MODE_EN | val = I2C_CNFG_NEW_MASTER_FSM | I2C_CNFG_PACKET_MODE_EN |
@ -651,7 +637,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
i2c_writel(i2c_dev, val, I2C_CNFG); i2c_writel(i2c_dev, val, I2C_CNFG);
i2c_writel(i2c_dev, 0, I2C_INT_MASK); i2c_writel(i2c_dev, 0, I2C_INT_MASK);
if (i2c_dev->is_vi) if (IS_VI(i2c_dev))
tegra_i2c_vi_init(i2c_dev); tegra_i2c_vi_init(i2c_dev);
switch (t->bus_freq_hz) { switch (t->bus_freq_hz) {
@ -703,7 +689,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
return err; return err;
} }
if (!i2c_dev->is_dvc && !i2c_dev->is_vi) { if (!IS_DVC(i2c_dev) && !IS_VI(i2c_dev)) {
u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG); u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG);
sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL; sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL;
@ -846,7 +832,7 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev)
i2c_dev->msg_buf_remaining = buf_remaining; i2c_dev->msg_buf_remaining = buf_remaining;
i2c_dev->msg_buf = buf + words_to_transfer * BYTES_PER_FIFO_WORD; i2c_dev->msg_buf = buf + words_to_transfer * BYTES_PER_FIFO_WORD;
if (i2c_dev->is_vi) if (IS_VI(i2c_dev))
i2c_writesl_vi(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer); i2c_writesl_vi(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer);
else else
i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer); i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer);
@ -933,7 +919,7 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
} }
i2c_writel(i2c_dev, status, I2C_INT_STATUS); i2c_writel(i2c_dev, status, I2C_INT_STATUS);
if (i2c_dev->is_dvc) if (IS_DVC(i2c_dev))
dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS); dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS);
/* /*
@ -972,15 +958,11 @@ err:
i2c_writel(i2c_dev, status, I2C_INT_STATUS); i2c_writel(i2c_dev, status, I2C_INT_STATUS);
if (i2c_dev->is_dvc) if (IS_DVC(i2c_dev))
dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS); dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS);
if (i2c_dev->dma_mode) { if (i2c_dev->dma_mode) {
if (i2c_dev->msg_read) dmaengine_terminate_async(i2c_dev->dma_chan);
dmaengine_terminate_async(i2c_dev->rx_dma_chan);
else
dmaengine_terminate_async(i2c_dev->tx_dma_chan);
complete(&i2c_dev->dma_complete); complete(&i2c_dev->dma_complete);
} }
@ -994,7 +976,6 @@ static void tegra_i2c_config_fifo_trig(struct tegra_i2c_dev *i2c_dev,
{ {
struct dma_slave_config slv_config = {0}; struct dma_slave_config slv_config = {0};
u32 val, reg, dma_burst, reg_offset; u32 val, reg, dma_burst, reg_offset;
struct dma_chan *chan;
int err; int err;
if (i2c_dev->hw->has_mst_fifo) if (i2c_dev->hw->has_mst_fifo)
@ -1011,7 +992,6 @@ static void tegra_i2c_config_fifo_trig(struct tegra_i2c_dev *i2c_dev,
dma_burst = 8; dma_burst = 8;
if (i2c_dev->msg_read) { if (i2c_dev->msg_read) {
chan = i2c_dev->rx_dma_chan;
reg_offset = tegra_i2c_reg_addr(i2c_dev, I2C_RX_FIFO); reg_offset = tegra_i2c_reg_addr(i2c_dev, I2C_RX_FIFO);
slv_config.src_addr = i2c_dev->base_phys + reg_offset; slv_config.src_addr = i2c_dev->base_phys + reg_offset;
@ -1023,7 +1003,6 @@ static void tegra_i2c_config_fifo_trig(struct tegra_i2c_dev *i2c_dev,
else else
val = I2C_FIFO_CONTROL_RX_TRIG(dma_burst); val = I2C_FIFO_CONTROL_RX_TRIG(dma_burst);
} else { } else {
chan = i2c_dev->tx_dma_chan;
reg_offset = tegra_i2c_reg_addr(i2c_dev, I2C_TX_FIFO); reg_offset = tegra_i2c_reg_addr(i2c_dev, I2C_TX_FIFO);
slv_config.dst_addr = i2c_dev->base_phys + reg_offset; slv_config.dst_addr = i2c_dev->base_phys + reg_offset;
@ -1037,7 +1016,7 @@ static void tegra_i2c_config_fifo_trig(struct tegra_i2c_dev *i2c_dev,
} }
slv_config.device_fc = true; slv_config.device_fc = true;
err = dmaengine_slave_config(chan, &slv_config); err = dmaengine_slave_config(i2c_dev->dma_chan, &slv_config);
if (err) { if (err) {
dev_err(i2c_dev->dev, "DMA config failed: %d\n", err); dev_err(i2c_dev->dev, "DMA config failed: %d\n", err);
dev_err(i2c_dev->dev, "falling back to PIO\n"); dev_err(i2c_dev->dev, "falling back to PIO\n");
@ -1347,13 +1326,8 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
* performs synchronization after the transfer's termination * performs synchronization after the transfer's termination
* and we want to get a completion if transfer succeeded. * and we want to get a completion if transfer succeeded.
*/ */
dmaengine_synchronize(i2c_dev->msg_read ? dmaengine_synchronize(i2c_dev->dma_chan);
i2c_dev->rx_dma_chan : dmaengine_terminate_sync(i2c_dev->dma_chan);
i2c_dev->tx_dma_chan);
dmaengine_terminate_sync(i2c_dev->msg_read ?
i2c_dev->rx_dma_chan :
i2c_dev->tx_dma_chan);
if (!time_left && !completion_done(&i2c_dev->dma_complete)) { if (!time_left && !completion_done(&i2c_dev->dma_complete)) {
dev_err(i2c_dev->dev, "DMA transfer timed out\n"); dev_err(i2c_dev->dev, "DMA transfer timed out\n");
@ -1654,13 +1628,17 @@ static const struct tegra_i2c_hw_feature tegra194_i2c_hw = {
static const struct of_device_id tegra_i2c_of_match[] = { static const struct of_device_id tegra_i2c_of_match[] = {
{ .compatible = "nvidia,tegra194-i2c", .data = &tegra194_i2c_hw, }, { .compatible = "nvidia,tegra194-i2c", .data = &tegra194_i2c_hw, },
{ .compatible = "nvidia,tegra186-i2c", .data = &tegra186_i2c_hw, }, { .compatible = "nvidia,tegra186-i2c", .data = &tegra186_i2c_hw, },
#if IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC)
{ .compatible = "nvidia,tegra210-i2c-vi", .data = &tegra210_i2c_hw, }, { .compatible = "nvidia,tegra210-i2c-vi", .data = &tegra210_i2c_hw, },
#endif
{ .compatible = "nvidia,tegra210-i2c", .data = &tegra210_i2c_hw, }, { .compatible = "nvidia,tegra210-i2c", .data = &tegra210_i2c_hw, },
{ .compatible = "nvidia,tegra124-i2c", .data = &tegra124_i2c_hw, }, { .compatible = "nvidia,tegra124-i2c", .data = &tegra124_i2c_hw, },
{ .compatible = "nvidia,tegra114-i2c", .data = &tegra114_i2c_hw, }, { .compatible = "nvidia,tegra114-i2c", .data = &tegra114_i2c_hw, },
{ .compatible = "nvidia,tegra30-i2c", .data = &tegra30_i2c_hw, }, { .compatible = "nvidia,tegra30-i2c", .data = &tegra30_i2c_hw, },
{ .compatible = "nvidia,tegra20-i2c", .data = &tegra20_i2c_hw, }, { .compatible = "nvidia,tegra20-i2c", .data = &tegra20_i2c_hw, },
#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)
{ .compatible = "nvidia,tegra20-i2c-dvc", .data = &tegra20_i2c_hw, }, { .compatible = "nvidia,tegra20-i2c-dvc", .data = &tegra20_i2c_hw, },
#endif
{}, {},
}; };
MODULE_DEVICE_TABLE(of, tegra_i2c_of_match); MODULE_DEVICE_TABLE(of, tegra_i2c_of_match);
@ -1675,10 +1653,12 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev)
multi_mode = device_property_read_bool(i2c_dev->dev, "multi-master"); multi_mode = device_property_read_bool(i2c_dev->dev, "multi-master");
i2c_dev->multimaster_mode = multi_mode; i2c_dev->multimaster_mode = multi_mode;
if (of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc")) if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc"))
i2c_dev->is_dvc = true; i2c_dev->is_dvc = true;
if (of_device_is_compatible(np, "nvidia,tegra210-i2c-vi")) if (IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) &&
of_device_is_compatible(np, "nvidia,tegra210-i2c-vi"))
i2c_dev->is_vi = true; i2c_dev->is_vi = true;
} }
@ -1707,7 +1687,7 @@ static int tegra_i2c_init_clocks(struct tegra_i2c_dev *i2c_dev)
if (i2c_dev->hw == &tegra20_i2c_hw || i2c_dev->hw == &tegra30_i2c_hw) if (i2c_dev->hw == &tegra20_i2c_hw || i2c_dev->hw == &tegra30_i2c_hw)
i2c_dev->clocks[i2c_dev->nclocks++].id = "fast-clk"; i2c_dev->clocks[i2c_dev->nclocks++].id = "fast-clk";
if (i2c_dev->is_vi) if (IS_VI(i2c_dev))
i2c_dev->clocks[i2c_dev->nclocks++].id = "slow"; i2c_dev->clocks[i2c_dev->nclocks++].id = "slow";
err = devm_clk_bulk_get(i2c_dev->dev, i2c_dev->nclocks, err = devm_clk_bulk_get(i2c_dev->dev, i2c_dev->nclocks,
@ -1825,7 +1805,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
* VI I2C device shouldn't be marked as IRQ-safe because VI I2C won't * VI I2C device shouldn't be marked as IRQ-safe because VI I2C won't
* be used for atomic transfers. * be used for atomic transfers.
*/ */
if (!i2c_dev->is_vi) if (!IS_VI(i2c_dev))
pm_runtime_irq_safe(i2c_dev->dev); pm_runtime_irq_safe(i2c_dev->dev);
pm_runtime_enable(i2c_dev->dev); pm_runtime_enable(i2c_dev->dev);
@ -1868,7 +1848,7 @@ release_clocks:
return err; return err;
} }
static int tegra_i2c_remove(struct platform_device *pdev) static void tegra_i2c_remove(struct platform_device *pdev)
{ {
struct tegra_i2c_dev *i2c_dev = platform_get_drvdata(pdev); struct tegra_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
@ -1877,8 +1857,6 @@ static int tegra_i2c_remove(struct platform_device *pdev)
tegra_i2c_release_dma(i2c_dev); tegra_i2c_release_dma(i2c_dev);
tegra_i2c_release_clocks(i2c_dev); tegra_i2c_release_clocks(i2c_dev);
return 0;
} }
static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev)
@ -1899,7 +1877,7 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev)
* power ON/OFF during runtime PM resume/suspend, meaning that * power ON/OFF during runtime PM resume/suspend, meaning that
* controller needs to be re-initialized after power ON. * controller needs to be re-initialized after power ON.
*/ */
if (i2c_dev->is_vi) { if (IS_VI(i2c_dev)) {
err = tegra_i2c_init(i2c_dev); err = tegra_i2c_init(i2c_dev);
if (err) if (err)
goto disable_clocks; goto disable_clocks;
@ -1987,7 +1965,7 @@ MODULE_DEVICE_TABLE(acpi, tegra_i2c_acpi_match);
static struct platform_driver tegra_i2c_driver = { static struct platform_driver tegra_i2c_driver = {
.probe = tegra_i2c_probe, .probe = tegra_i2c_probe,
.remove = tegra_i2c_remove, .remove_new = tegra_i2c_remove,
.driver = { .driver = {
.name = "tegra-i2c", .name = "tegra-i2c",
.of_match_table = tegra_i2c_of_match, .of_match_table = tegra_i2c_of_match,

View File

@ -226,10 +226,8 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface,
/* allocate memory for our device state and initialize it */ /* allocate memory for our device state and initialize it */
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL) { if (!dev)
dev_err(&interface->dev, "Out of memory\n");
goto error; goto error;
}
dev->usb_dev = usb_get_dev(interface_to_usbdev(interface)); dev->usb_dev = usb_get_dev(interface_to_usbdev(interface));
dev->interface = interface; dev->interface = interface;

View File

@ -540,21 +540,16 @@ static int uniphier_fi2c_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
priv->clk = devm_clk_get(dev, NULL); priv->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(priv->clk)) { if (IS_ERR(priv->clk)) {
dev_err(dev, "failed to get clock\n"); dev_err(dev, "failed to enable clock\n");
return PTR_ERR(priv->clk); return PTR_ERR(priv->clk);
} }
ret = clk_prepare_enable(priv->clk);
if (ret)
return ret;
clk_rate = clk_get_rate(priv->clk); clk_rate = clk_get_rate(priv->clk);
if (!clk_rate) { if (!clk_rate) {
dev_err(dev, "input clock rate should not be zero\n"); dev_err(dev, "input clock rate should not be zero\n");
ret = -EINVAL; return -EINVAL;
goto disable_clk;
} }
priv->clk_cycle = clk_rate / bus_speed; priv->clk_cycle = clk_rate / bus_speed;
@ -575,25 +570,17 @@ static int uniphier_fi2c_probe(struct platform_device *pdev)
pdev->name, priv); pdev->name, priv);
if (ret) { if (ret) {
dev_err(dev, "failed to request irq %d\n", irq); dev_err(dev, "failed to request irq %d\n", irq);
goto disable_clk;
}
ret = i2c_add_adapter(&priv->adap);
disable_clk:
if (ret)
clk_disable_unprepare(priv->clk);
return ret; return ret;
} }
static int uniphier_fi2c_remove(struct platform_device *pdev) return i2c_add_adapter(&priv->adap);
}
static void uniphier_fi2c_remove(struct platform_device *pdev)
{ {
struct uniphier_fi2c_priv *priv = platform_get_drvdata(pdev); struct uniphier_fi2c_priv *priv = platform_get_drvdata(pdev);
i2c_del_adapter(&priv->adap); i2c_del_adapter(&priv->adap);
clk_disable_unprepare(priv->clk);
return 0;
} }
static int __maybe_unused uniphier_fi2c_suspend(struct device *dev) static int __maybe_unused uniphier_fi2c_suspend(struct device *dev)
@ -631,7 +618,7 @@ MODULE_DEVICE_TABLE(of, uniphier_fi2c_match);
static struct platform_driver uniphier_fi2c_drv = { static struct platform_driver uniphier_fi2c_drv = {
.probe = uniphier_fi2c_probe, .probe = uniphier_fi2c_probe,
.remove = uniphier_fi2c_remove, .remove_new = uniphier_fi2c_remove,
.driver = { .driver = {
.name = "uniphier-fi2c", .name = "uniphier-fi2c",
.of_match_table = uniphier_fi2c_match, .of_match_table = uniphier_fi2c_match,

View File

@ -335,21 +335,16 @@ static int uniphier_i2c_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
priv->clk = devm_clk_get(dev, NULL); priv->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(priv->clk)) { if (IS_ERR(priv->clk)) {
dev_err(dev, "failed to get clock\n"); dev_err(dev, "failed to enable clock\n");
return PTR_ERR(priv->clk); return PTR_ERR(priv->clk);
} }
ret = clk_prepare_enable(priv->clk);
if (ret)
return ret;
clk_rate = clk_get_rate(priv->clk); clk_rate = clk_get_rate(priv->clk);
if (!clk_rate) { if (!clk_rate) {
dev_err(dev, "input clock rate should not be zero\n"); dev_err(dev, "input clock rate should not be zero\n");
ret = -EINVAL; return -EINVAL;
goto disable_clk;
} }
priv->clk_cycle = clk_rate / bus_speed; priv->clk_cycle = clk_rate / bus_speed;
@ -369,25 +364,17 @@ static int uniphier_i2c_probe(struct platform_device *pdev)
priv); priv);
if (ret) { if (ret) {
dev_err(dev, "failed to request irq %d\n", irq); dev_err(dev, "failed to request irq %d\n", irq);
goto disable_clk;
}
ret = i2c_add_adapter(&priv->adap);
disable_clk:
if (ret)
clk_disable_unprepare(priv->clk);
return ret; return ret;
} }
static int uniphier_i2c_remove(struct platform_device *pdev) return i2c_add_adapter(&priv->adap);
}
static void uniphier_i2c_remove(struct platform_device *pdev)
{ {
struct uniphier_i2c_priv *priv = platform_get_drvdata(pdev); struct uniphier_i2c_priv *priv = platform_get_drvdata(pdev);
i2c_del_adapter(&priv->adap); i2c_del_adapter(&priv->adap);
clk_disable_unprepare(priv->clk);
return 0;
} }
static int __maybe_unused uniphier_i2c_suspend(struct device *dev) static int __maybe_unused uniphier_i2c_suspend(struct device *dev)
@ -425,7 +412,7 @@ MODULE_DEVICE_TABLE(of, uniphier_i2c_match);
static struct platform_driver uniphier_i2c_drv = { static struct platform_driver uniphier_i2c_drv = {
.probe = uniphier_i2c_probe, .probe = uniphier_i2c_probe,
.remove = uniphier_i2c_remove, .remove_new = uniphier_i2c_remove,
.driver = { .driver = {
.name = "uniphier-i2c", .name = "uniphier-i2c",
.of_match_table = uniphier_i2c_match, .of_match_table = uniphier_i2c_match,

View File

@ -64,15 +64,13 @@ static const struct i2c_algo_bit_data i2c_versatile_algo = {
static int i2c_versatile_probe(struct platform_device *dev) static int i2c_versatile_probe(struct platform_device *dev)
{ {
struct i2c_versatile *i2c; struct i2c_versatile *i2c;
struct resource *r;
int ret; int ret;
i2c = devm_kzalloc(&dev->dev, sizeof(struct i2c_versatile), GFP_KERNEL); i2c = devm_kzalloc(&dev->dev, sizeof(struct i2c_versatile), GFP_KERNEL);
if (!i2c) if (!i2c)
return -ENOMEM; return -ENOMEM;
r = platform_get_resource(dev, IORESOURCE_MEM, 0); i2c->base = devm_platform_get_and_ioremap_resource(dev, 0, NULL);
i2c->base = devm_ioremap_resource(&dev->dev, r);
if (IS_ERR(i2c->base)) if (IS_ERR(i2c->base))
return PTR_ERR(i2c->base); return PTR_ERR(i2c->base);
@ -96,12 +94,11 @@ static int i2c_versatile_probe(struct platform_device *dev)
return 0; return 0;
} }
static int i2c_versatile_remove(struct platform_device *dev) static void i2c_versatile_remove(struct platform_device *dev)
{ {
struct i2c_versatile *i2c = platform_get_drvdata(dev); struct i2c_versatile *i2c = platform_get_drvdata(dev);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
return 0;
} }
static const struct of_device_id i2c_versatile_match[] = { static const struct of_device_id i2c_versatile_match[] = {
@ -112,7 +109,7 @@ MODULE_DEVICE_TABLE(of, i2c_versatile_match);
static struct platform_driver i2c_versatile_driver = { static struct platform_driver i2c_versatile_driver = {
.probe = i2c_versatile_probe, .probe = i2c_versatile_probe,
.remove = i2c_versatile_remove, .remove_new = i2c_versatile_remove,
.driver = { .driver = {
.name = "versatile-i2c", .name = "versatile-i2c",
.of_match_table = i2c_versatile_match, .of_match_table = i2c_versatile_match,

View File

@ -407,20 +407,18 @@ static int vprbrd_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int vprbrd_i2c_remove(struct platform_device *pdev) static void vprbrd_i2c_remove(struct platform_device *pdev)
{ {
struct vprbrd_i2c *vb_i2c = platform_get_drvdata(pdev); struct vprbrd_i2c *vb_i2c = platform_get_drvdata(pdev);
i2c_del_adapter(&vb_i2c->i2c); i2c_del_adapter(&vb_i2c->i2c);
return 0;
} }
static struct platform_driver vprbrd_i2c_driver = { static struct platform_driver vprbrd_i2c_driver = {
.driver.name = "viperboard-i2c", .driver.name = "viperboard-i2c",
.driver.owner = THIS_MODULE, .driver.owner = THIS_MODULE,
.probe = vprbrd_i2c_probe, .probe = vprbrd_i2c_probe,
.remove = vprbrd_i2c_remove, .remove_new = vprbrd_i2c_remove,
}; };
static int __init vprbrd_i2c_init(void) static int __init vprbrd_i2c_init(void)

View File

@ -372,7 +372,6 @@ static int wmt_i2c_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct wmt_i2c_dev *i2c_dev; struct wmt_i2c_dev *i2c_dev;
struct i2c_adapter *adap; struct i2c_adapter *adap;
struct resource *res;
int err; int err;
u32 clk_rate; u32 clk_rate;
@ -380,8 +379,7 @@ static int wmt_i2c_probe(struct platform_device *pdev)
if (!i2c_dev) if (!i2c_dev)
return -ENOMEM; return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); i2c_dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
i2c_dev->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(i2c_dev->base)) if (IS_ERR(i2c_dev->base))
return PTR_ERR(i2c_dev->base); return PTR_ERR(i2c_dev->base);
@ -436,7 +434,7 @@ static int wmt_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int wmt_i2c_remove(struct platform_device *pdev) static void wmt_i2c_remove(struct platform_device *pdev)
{ {
struct wmt_i2c_dev *i2c_dev = platform_get_drvdata(pdev); struct wmt_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
@ -444,8 +442,6 @@ static int wmt_i2c_remove(struct platform_device *pdev)
writew(0, i2c_dev->base + REG_IMR); writew(0, i2c_dev->base + REG_IMR);
clk_disable_unprepare(i2c_dev->clk); clk_disable_unprepare(i2c_dev->clk);
i2c_del_adapter(&i2c_dev->adapter); i2c_del_adapter(&i2c_dev->adapter);
return 0;
} }
static const struct of_device_id wmt_i2c_dt_ids[] = { static const struct of_device_id wmt_i2c_dt_ids[] = {
@ -455,7 +451,7 @@ static const struct of_device_id wmt_i2c_dt_ids[] = {
static struct platform_driver wmt_i2c_driver = { static struct platform_driver wmt_i2c_driver = {
.probe = wmt_i2c_probe, .probe = wmt_i2c_probe,
.remove = wmt_i2c_remove, .remove_new = wmt_i2c_remove,
.driver = { .driver = {
.name = "wmt-i2c", .name = "wmt-i2c",
.of_match_table = wmt_i2c_dt_ids, .of_match_table = wmt_i2c_dt_ids,

View File

@ -560,7 +560,7 @@ mbox_err:
return rc; return rc;
} }
static int xgene_slimpro_i2c_remove(struct platform_device *pdev) static void xgene_slimpro_i2c_remove(struct platform_device *pdev)
{ {
struct slimpro_i2c_dev *ctx = platform_get_drvdata(pdev); struct slimpro_i2c_dev *ctx = platform_get_drvdata(pdev);
@ -570,8 +570,6 @@ static int xgene_slimpro_i2c_remove(struct platform_device *pdev)
mbox_free_channel(ctx->mbox_chan); mbox_free_channel(ctx->mbox_chan);
else else
pcc_mbox_free_channel(ctx->pcc_chan); pcc_mbox_free_channel(ctx->pcc_chan);
return 0;
} }
static const struct of_device_id xgene_slimpro_i2c_dt_ids[] = { static const struct of_device_id xgene_slimpro_i2c_dt_ids[] = {
@ -591,7 +589,7 @@ MODULE_DEVICE_TABLE(acpi, xgene_slimpro_i2c_acpi_ids);
static struct platform_driver xgene_slimpro_i2c_driver = { static struct platform_driver xgene_slimpro_i2c_driver = {
.probe = xgene_slimpro_i2c_probe, .probe = xgene_slimpro_i2c_probe,
.remove = xgene_slimpro_i2c_remove, .remove_new = xgene_slimpro_i2c_remove,
.driver = { .driver = {
.name = "xgene-slimpro-i2c", .name = "xgene-slimpro-i2c",
.of_match_table = of_match_ptr(xgene_slimpro_i2c_dt_ids), .of_match_table = of_match_ptr(xgene_slimpro_i2c_dt_ids),

View File

@ -1256,16 +1256,11 @@ static int xiic_i2c_probe(struct platform_device *pdev)
mutex_init(&i2c->lock); mutex_init(&i2c->lock);
i2c->clk = devm_clk_get(&pdev->dev, NULL); i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(i2c->clk)) if (IS_ERR(i2c->clk))
return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk), return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
"input clock not found.\n"); "failed to enable input clock.\n");
ret = clk_prepare_enable(i2c->clk);
if (ret) {
dev_err(&pdev->dev, "Unable to enable clock.\n");
return ret;
}
i2c->dev = &pdev->dev; i2c->dev = &pdev->dev;
pm_runtime_set_autosuspend_delay(i2c->dev, XIIC_PM_TIMEOUT); pm_runtime_set_autosuspend_delay(i2c->dev, XIIC_PM_TIMEOUT);
pm_runtime_use_autosuspend(i2c->dev); pm_runtime_use_autosuspend(i2c->dev);
@ -1286,7 +1281,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Cannot claim IRQ\n"); dev_err(&pdev->dev, "Cannot claim IRQ\n");
goto err_clk_dis; goto err_pm_disable;
} }
i2c->singlemaster = i2c->singlemaster =
@ -1307,14 +1302,14 @@ static int xiic_i2c_probe(struct platform_device *pdev)
ret = xiic_reinit(i2c); ret = xiic_reinit(i2c);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Cannot xiic_reinit\n"); dev_err(&pdev->dev, "Cannot xiic_reinit\n");
goto err_clk_dis; goto err_pm_disable;
} }
/* add i2c adapter to i2c tree */ /* add i2c adapter to i2c tree */
ret = i2c_add_adapter(&i2c->adap); ret = i2c_add_adapter(&i2c->adap);
if (ret) { if (ret) {
xiic_deinit(i2c); xiic_deinit(i2c);
goto err_clk_dis; goto err_pm_disable;
} }
if (pdata) { if (pdata) {
@ -1328,14 +1323,14 @@ static int xiic_i2c_probe(struct platform_device *pdev)
return 0; return 0;
err_clk_dis: err_pm_disable:
pm_runtime_set_suspended(&pdev->dev); pm_runtime_set_suspended(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
clk_disable_unprepare(i2c->clk);
return ret; return ret;
} }
static int xiic_i2c_remove(struct platform_device *pdev) static void xiic_i2c_remove(struct platform_device *pdev)
{ {
struct xiic_i2c *i2c = platform_get_drvdata(pdev); struct xiic_i2c *i2c = platform_get_drvdata(pdev);
int ret; int ret;
@ -1352,12 +1347,9 @@ static int xiic_i2c_remove(struct platform_device *pdev)
xiic_deinit(i2c); xiic_deinit(i2c);
pm_runtime_put_sync(i2c->dev); pm_runtime_put_sync(i2c->dev);
clk_disable_unprepare(i2c->clk);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev); pm_runtime_set_suspended(&pdev->dev);
pm_runtime_dont_use_autosuspend(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev);
return 0;
} }
static int __maybe_unused xiic_i2c_runtime_suspend(struct device *dev) static int __maybe_unused xiic_i2c_runtime_suspend(struct device *dev)
@ -1390,7 +1382,7 @@ static const struct dev_pm_ops xiic_dev_pm_ops = {
static struct platform_driver xiic_i2c_driver = { static struct platform_driver xiic_i2c_driver = {
.probe = xiic_i2c_probe, .probe = xiic_i2c_probe,
.remove = xiic_i2c_remove, .remove_new = xiic_i2c_remove,
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.of_match_table = of_match_ptr(xiic_of_match), .of_match_table = of_match_ptr(xiic_of_match),

View File

@ -559,7 +559,7 @@ static int xlp9xx_i2c_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int xlp9xx_i2c_remove(struct platform_device *pdev) static void xlp9xx_i2c_remove(struct platform_device *pdev)
{ {
struct xlp9xx_i2c_dev *priv; struct xlp9xx_i2c_dev *priv;
@ -568,8 +568,6 @@ static int xlp9xx_i2c_remove(struct platform_device *pdev)
synchronize_irq(priv->irq); synchronize_irq(priv->irq);
i2c_del_adapter(&priv->adapter); i2c_del_adapter(&priv->adapter);
xlp9xx_write_i2c_reg(priv, XLP9XX_I2C_CTRL, 0); xlp9xx_write_i2c_reg(priv, XLP9XX_I2C_CTRL, 0);
return 0;
} }
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
@ -583,7 +581,7 @@ MODULE_DEVICE_TABLE(acpi, xlp9xx_i2c_acpi_ids);
static struct platform_driver xlp9xx_i2c_driver = { static struct platform_driver xlp9xx_i2c_driver = {
.probe = xlp9xx_i2c_probe, .probe = xlp9xx_i2c_probe,
.remove = xlp9xx_i2c_remove, .remove_new = xlp9xx_i2c_remove,
.driver = { .driver = {
.name = "xlp9xx-i2c", .name = "xlp9xx-i2c",
.acpi_match_table = ACPI_PTR(xlp9xx_i2c_acpi_ids), .acpi_match_table = ACPI_PTR(xlp9xx_i2c_acpi_ids),

View File

@ -523,14 +523,12 @@ static void scx200_cleanup_iface(struct scx200_acb_iface *iface)
kfree(iface); kfree(iface);
} }
static int scx200_remove(struct platform_device *pdev) static void scx200_remove(struct platform_device *pdev)
{ {
struct scx200_acb_iface *iface; struct scx200_acb_iface *iface;
iface = platform_get_drvdata(pdev); iface = platform_get_drvdata(pdev);
scx200_cleanup_iface(iface); scx200_cleanup_iface(iface);
return 0;
} }
static struct platform_driver scx200_pci_driver = { static struct platform_driver scx200_pci_driver = {
@ -538,7 +536,7 @@ static struct platform_driver scx200_pci_driver = {
.name = "cs5535-smb", .name = "cs5535-smb",
}, },
.probe = scx200_probe, .probe = scx200_probe,
.remove = scx200_remove, .remove_new = scx200_remove,
}; };
static const struct pci_device_id scx200_isa[] = { static const struct pci_device_id scx200_isa[] = {

View File

@ -114,6 +114,25 @@ const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
} }
EXPORT_SYMBOL_GPL(i2c_match_id); EXPORT_SYMBOL_GPL(i2c_match_id);
const void *i2c_get_match_data(const struct i2c_client *client)
{
struct i2c_driver *driver = to_i2c_driver(client->dev.driver);
const struct i2c_device_id *match;
const void *data;
data = device_get_match_data(&client->dev);
if (!data) {
match = i2c_match_id(driver->id_table, client);
if (!match)
return NULL;
data = (const void *)match->driver_data;
}
return data;
}
EXPORT_SYMBOL(i2c_get_match_data);
static int i2c_device_match(struct device *dev, struct device_driver *drv) static int i2c_device_match(struct device *dev, struct device_driver *drv)
{ {
struct i2c_client *client = i2c_verify_client(dev); struct i2c_client *client = i2c_verify_client(dev);

View File

@ -174,13 +174,12 @@ static int i2c_arbitrator_probe(struct platform_device *pdev)
return ret; return ret;
} }
static int i2c_arbitrator_remove(struct platform_device *pdev) static void i2c_arbitrator_remove(struct platform_device *pdev)
{ {
struct i2c_mux_core *muxc = platform_get_drvdata(pdev); struct i2c_mux_core *muxc = platform_get_drvdata(pdev);
i2c_mux_del_adapters(muxc); i2c_mux_del_adapters(muxc);
i2c_put_adapter(muxc->parent); i2c_put_adapter(muxc->parent);
return 0;
} }
static const struct of_device_id i2c_arbitrator_of_match[] = { static const struct of_device_id i2c_arbitrator_of_match[] = {
@ -191,7 +190,7 @@ MODULE_DEVICE_TABLE(of, i2c_arbitrator_of_match);
static struct platform_driver i2c_arbitrator_driver = { static struct platform_driver i2c_arbitrator_driver = {
.probe = i2c_arbitrator_probe, .probe = i2c_arbitrator_probe,
.remove = i2c_arbitrator_remove, .remove_new = i2c_arbitrator_remove,
.driver = { .driver = {
.name = "i2c-arb-gpio-challenge", .name = "i2c-arb-gpio-challenge",
.of_match_table = i2c_arbitrator_of_match, .of_match_table = i2c_arbitrator_of_match,

View File

@ -282,7 +282,7 @@ err_rollback:
return err; return err;
} }
static int i2c_demux_pinctrl_remove(struct platform_device *pdev) static void i2c_demux_pinctrl_remove(struct platform_device *pdev)
{ {
struct i2c_demux_pinctrl_priv *priv = platform_get_drvdata(pdev); struct i2c_demux_pinctrl_priv *priv = platform_get_drvdata(pdev);
int i; int i;
@ -296,8 +296,6 @@ static int i2c_demux_pinctrl_remove(struct platform_device *pdev)
of_node_put(priv->chan[i].parent_np); of_node_put(priv->chan[i].parent_np);
of_changeset_destroy(&priv->chan[i].chgset); of_changeset_destroy(&priv->chan[i].chgset);
} }
return 0;
} }
static const struct of_device_id i2c_demux_pinctrl_of_match[] = { static const struct of_device_id i2c_demux_pinctrl_of_match[] = {
@ -312,7 +310,7 @@ static struct platform_driver i2c_demux_pinctrl_driver = {
.of_match_table = i2c_demux_pinctrl_of_match, .of_match_table = i2c_demux_pinctrl_of_match,
}, },
.probe = i2c_demux_pinctrl_probe, .probe = i2c_demux_pinctrl_probe,
.remove = i2c_demux_pinctrl_remove, .remove_new = i2c_demux_pinctrl_remove,
}; };
module_platform_driver(i2c_demux_pinctrl_driver); module_platform_driver(i2c_demux_pinctrl_driver);

View File

@ -225,14 +225,12 @@ alloc_failed:
return ret; return ret;
} }
static int i2c_mux_gpio_remove(struct platform_device *pdev) static void i2c_mux_gpio_remove(struct platform_device *pdev)
{ {
struct i2c_mux_core *muxc = platform_get_drvdata(pdev); struct i2c_mux_core *muxc = platform_get_drvdata(pdev);
i2c_mux_del_adapters(muxc); i2c_mux_del_adapters(muxc);
i2c_put_adapter(muxc->parent); i2c_put_adapter(muxc->parent);
return 0;
} }
static const struct of_device_id i2c_mux_gpio_of_match[] = { static const struct of_device_id i2c_mux_gpio_of_match[] = {
@ -243,7 +241,7 @@ MODULE_DEVICE_TABLE(of, i2c_mux_gpio_of_match);
static struct platform_driver i2c_mux_gpio_driver = { static struct platform_driver i2c_mux_gpio_driver = {
.probe = i2c_mux_gpio_probe, .probe = i2c_mux_gpio_probe,
.remove = i2c_mux_gpio_remove, .remove_new = i2c_mux_gpio_remove,
.driver = { .driver = {
.name = "i2c-mux-gpio", .name = "i2c-mux-gpio",
.of_match_table = i2c_mux_gpio_of_match, .of_match_table = i2c_mux_gpio_of_match,

View File

@ -142,19 +142,17 @@ err_parent:
return ret; return ret;
} }
static int i2c_mux_remove(struct platform_device *pdev) static void i2c_mux_remove(struct platform_device *pdev)
{ {
struct i2c_mux_core *muxc = platform_get_drvdata(pdev); struct i2c_mux_core *muxc = platform_get_drvdata(pdev);
i2c_mux_del_adapters(muxc); i2c_mux_del_adapters(muxc);
i2c_put_adapter(muxc->parent); i2c_put_adapter(muxc->parent);
return 0;
} }
static struct platform_driver i2c_mux_driver = { static struct platform_driver i2c_mux_driver = {
.probe = i2c_mux_probe, .probe = i2c_mux_probe,
.remove = i2c_mux_remove, .remove_new = i2c_mux_remove,
.driver = { .driver = {
.name = "i2c-mux-gpmux", .name = "i2c-mux-gpmux",
.of_match_table = i2c_mux_of_match, .of_match_table = i2c_mux_of_match,

View File

@ -170,12 +170,11 @@ virt_reg_failed:
return err; return err;
} }
static int mlxcpld_mux_remove(struct platform_device *pdev) static void mlxcpld_mux_remove(struct platform_device *pdev)
{ {
struct i2c_mux_core *muxc = platform_get_drvdata(pdev); struct i2c_mux_core *muxc = platform_get_drvdata(pdev);
i2c_mux_del_adapters(muxc); i2c_mux_del_adapters(muxc);
return 0;
} }
static struct platform_driver mlxcpld_mux_driver = { static struct platform_driver mlxcpld_mux_driver = {
@ -183,7 +182,7 @@ static struct platform_driver mlxcpld_mux_driver = {
.name = "i2c-mux-mlxcpld", .name = "i2c-mux-mlxcpld",
}, },
.probe = mlxcpld_mux_probe, .probe = mlxcpld_mux_probe,
.remove = mlxcpld_mux_remove, .remove_new = mlxcpld_mux_remove,
}; };
module_platform_driver(mlxcpld_mux_driver); module_platform_driver(mlxcpld_mux_driver);

View File

@ -166,14 +166,12 @@ err_put_parent:
return ret; return ret;
} }
static int i2c_mux_pinctrl_remove(struct platform_device *pdev) static void i2c_mux_pinctrl_remove(struct platform_device *pdev)
{ {
struct i2c_mux_core *muxc = platform_get_drvdata(pdev); struct i2c_mux_core *muxc = platform_get_drvdata(pdev);
i2c_mux_del_adapters(muxc); i2c_mux_del_adapters(muxc);
i2c_put_adapter(muxc->parent); i2c_put_adapter(muxc->parent);
return 0;
} }
static const struct of_device_id i2c_mux_pinctrl_of_match[] = { static const struct of_device_id i2c_mux_pinctrl_of_match[] = {
@ -188,7 +186,7 @@ static struct platform_driver i2c_mux_pinctrl_driver = {
.of_match_table = i2c_mux_pinctrl_of_match, .of_match_table = i2c_mux_pinctrl_of_match,
}, },
.probe = i2c_mux_pinctrl_probe, .probe = i2c_mux_pinctrl_probe,
.remove = i2c_mux_pinctrl_remove, .remove_new = i2c_mux_pinctrl_remove,
}; };
module_platform_driver(i2c_mux_pinctrl_driver); module_platform_driver(i2c_mux_pinctrl_driver);

View File

@ -233,14 +233,12 @@ err_put_parent:
return ret; return ret;
} }
static int i2c_mux_reg_remove(struct platform_device *pdev) static void i2c_mux_reg_remove(struct platform_device *pdev)
{ {
struct i2c_mux_core *muxc = platform_get_drvdata(pdev); struct i2c_mux_core *muxc = platform_get_drvdata(pdev);
i2c_mux_del_adapters(muxc); i2c_mux_del_adapters(muxc);
i2c_put_adapter(muxc->parent); i2c_put_adapter(muxc->parent);
return 0;
} }
static const struct of_device_id i2c_mux_reg_of_match[] = { static const struct of_device_id i2c_mux_reg_of_match[] = {
@ -251,7 +249,7 @@ MODULE_DEVICE_TABLE(of, i2c_mux_reg_of_match);
static struct platform_driver i2c_mux_reg_driver = { static struct platform_driver i2c_mux_reg_driver = {
.probe = i2c_mux_reg_probe, .probe = i2c_mux_reg_probe,
.remove = i2c_mux_reg_remove, .remove_new = i2c_mux_reg_remove,
.driver = { .driver = {
.name = "i2c-mux-reg", .name = "i2c-mux-reg",
.of_match_table = of_match_ptr(i2c_mux_reg_of_match), .of_match_table = of_match_ptr(i2c_mux_reg_of_match),

Some files were not shown because too many files have changed in this diff Show More