root/drivers/mfd/sky81452.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sky81452_probe

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  * sky81452.c   SKY81452 MFD driver
   4  *
   5  * Copyright 2014 Skyworks Solutions Inc.
   6  * Author : Gyungoh Yoo <jack.yoo@skyworksinc.com>
   7  */
   8 
   9 #include <linux/kernel.h>
  10 #include <linux/module.h>
  11 #include <linux/init.h>
  12 #include <linux/err.h>
  13 #include <linux/slab.h>
  14 #include <linux/i2c.h>
  15 #include <linux/regmap.h>
  16 #include <linux/mfd/core.h>
  17 #include <linux/mfd/sky81452.h>
  18 
  19 static const struct regmap_config sky81452_config = {
  20         .reg_bits = 8,
  21         .val_bits = 8,
  22 };
  23 
  24 static int sky81452_probe(struct i2c_client *client,
  25                                 const struct i2c_device_id *id)
  26 {
  27         struct device *dev = &client->dev;
  28         const struct sky81452_platform_data *pdata = dev_get_platdata(dev);
  29         struct mfd_cell cells[2];
  30         struct regmap *regmap;
  31         int ret;
  32 
  33         if (!pdata) {
  34                 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
  35                 if (!pdata)
  36                         return -ENOMEM;
  37         }
  38 
  39         regmap = devm_regmap_init_i2c(client, &sky81452_config);
  40         if (IS_ERR(regmap)) {
  41                 dev_err(dev, "failed to initialize.err=%ld\n", PTR_ERR(regmap));
  42                 return PTR_ERR(regmap);
  43         }
  44 
  45         i2c_set_clientdata(client, regmap);
  46 
  47         memset(cells, 0, sizeof(cells));
  48         cells[0].name = "sky81452-backlight";
  49         cells[0].of_compatible = "skyworks,sky81452-backlight";
  50         cells[0].platform_data = pdata->bl_pdata;
  51         cells[0].pdata_size = sizeof(*pdata->bl_pdata);
  52         cells[1].name = "sky81452-regulator";
  53         cells[1].platform_data = pdata->regulator_init_data;
  54         cells[1].pdata_size = sizeof(*pdata->regulator_init_data);
  55 
  56         ret = devm_mfd_add_devices(dev, -1, cells, ARRAY_SIZE(cells),
  57                                    NULL, 0, NULL);
  58         if (ret)
  59                 dev_err(dev, "failed to add child devices. err=%d\n", ret);
  60 
  61         return ret;
  62 }
  63 
  64 static const struct i2c_device_id sky81452_ids[] = {
  65         { "sky81452" },
  66         { }
  67 };
  68 MODULE_DEVICE_TABLE(i2c, sky81452_ids);
  69 
  70 #ifdef CONFIG_OF
  71 static const struct of_device_id sky81452_of_match[] = {
  72         { .compatible = "skyworks,sky81452", },
  73         { }
  74 };
  75 MODULE_DEVICE_TABLE(of, sky81452_of_match);
  76 #endif
  77 
  78 static struct i2c_driver sky81452_driver = {
  79         .driver = {
  80                 .name = "sky81452",
  81                 .of_match_table = of_match_ptr(sky81452_of_match),
  82         },
  83         .probe = sky81452_probe,
  84         .id_table = sky81452_ids,
  85 };
  86 
  87 module_i2c_driver(sky81452_driver);
  88 
  89 MODULE_DESCRIPTION("Skyworks SKY81452 MFD driver");
  90 MODULE_AUTHOR("Gyungoh Yoo <jack.yoo@skyworksinc.com>");
  91 MODULE_LICENSE("GPL v2");

/* [<][>][^][v][top][bottom][index][help] */