Re: [PATCH v4 36/48] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Miquel,

I love your patch! Perhaps something to improve:

[auto build test WARNING on lee-mfd/for-mfd-next]
[also build test WARNING on jic23-iio/togreg robh/for-next v5.15-rc3 next-20210922]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Miquel-Raynal/TI-AM437X-ADC1/20210928-213524
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next
config: microblaze-randconfig-r033-20210928 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/43a01cf6413f2be038b0d466c7c3f6f16b40e2c3
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Miquel-Raynal/TI-AM437X-ADC1/20210928-213524
        git checkout 43a01cf6413f2be038b0d466c7c3f6f16b40e2c3
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=microblaze 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   drivers/mfd/ti_am335x_tscadc.c: In function 'ti_tscadc_probe':
>> drivers/mfd/ti_am335x_tscadc.c:124:31: warning: variable 'use_mag' set but not used [-Wunused-but-set-variable]
     124 |         bool use_tsc = false, use_mag = false;
         |                               ^~~~~~~
   In file included from drivers/mfd/ti_am335x_tscadc.c:20:
   drivers/mfd/ti_am335x_tscadc.c: At top level:
   include/linux/mfd/ti_am335x_tscadc.h:126:38: error: 'HZ_PER_MHZ' undeclared here (not in a function)
     126 | #define TSC_ADC_CLK             (3 * HZ_PER_MHZ)
         |                                      ^~~~~~~~~~
   drivers/mfd/ti_am335x_tscadc.c:354:28: note: in expansion of macro 'TSC_ADC_CLK'
     354 |         .target_clk_rate = TSC_ADC_CLK,
         |                            ^~~~~~~~~~~


vim +/use_mag +124 drivers/mfd/ti_am335x_tscadc.c

   114	
   115	static	int ti_tscadc_probe(struct platform_device *pdev)
   116	{
   117		struct ti_tscadc_dev *tscadc;
   118		struct resource *res;
   119		struct clk *clk;
   120		struct device_node *node;
   121		struct mfd_cell *cell;
   122		struct property *prop;
   123		const __be32 *cur;
 > 124		bool use_tsc = false, use_mag = false;
   125		u32 val;
   126		int err;
   127		int tscmag_wires = 0, adc_channels = 0, cell_idx = 0, total_channels;
   128		int readouts = 0, mag_tracks = 0;
   129	
   130		/* Allocate memory for device */
   131		tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
   132		if (!tscadc)
   133			return -ENOMEM;
   134	
   135		tscadc->dev = &pdev->dev;
   136	
   137		if (!pdev->dev.of_node) {
   138			dev_err(&pdev->dev, "Could not find valid DT data.\n");
   139			return -EINVAL;
   140		}
   141	
   142		tscadc->data = of_device_get_match_data(&pdev->dev);
   143	
   144		if (ti_adc_with_touchscreen(tscadc)) {
   145			node = of_get_child_by_name(pdev->dev.of_node, "tsc");
   146			of_property_read_u32(node, "ti,wires", &tscmag_wires);
   147			of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
   148			of_node_put(node);
   149			if (tscmag_wires)
   150				use_tsc = true;
   151		} else {
   152			/*
   153			 * When adding support for the magnetic stripe reader, here is
   154			 * the place to look for the number of tracks used from device
   155			 * tree. Let's default to 0 for now.
   156			 */
   157			mag_tracks = 0;
   158			tscmag_wires = mag_tracks * 2;
   159			if (tscmag_wires)
   160				use_mag = true;
   161		}
   162	
   163		node = of_get_child_by_name(pdev->dev.of_node, "adc");
   164		of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
   165			adc_channels++;
   166			if (val > 7) {
   167				dev_err(&pdev->dev, " PIN numbers are 0..7 (not %d)\n",
   168					val);
   169				of_node_put(node);
   170				return -EINVAL;
   171			}
   172		}
   173	
   174		of_node_put(node);
   175	
   176		total_channels = tscmag_wires + adc_channels;
   177		if (total_channels > 8) {
   178			dev_err(&pdev->dev, "Number of i/p channels more than 8\n");
   179			return -EINVAL;
   180		}
   181	
   182		if (total_channels == 0) {
   183			dev_err(&pdev->dev, "Need atleast one channel.\n");
   184			return -EINVAL;
   185		}
   186	
   187		if (use_tsc && (readouts * 2 + 2 + adc_channels > 16)) {
   188			dev_err(&pdev->dev, "Too many step configurations requested\n");
   189			return -EINVAL;
   190		}
   191	
   192		err = platform_get_irq(pdev, 0);
   193		if (err < 0)
   194			return err;
   195		else
   196			tscadc->irq = err;
   197	
   198		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   199		tscadc->tscadc_base = devm_ioremap_resource(&pdev->dev, res);
   200		if (IS_ERR(tscadc->tscadc_base))
   201			return PTR_ERR(tscadc->tscadc_base);
   202	
   203		tscadc->tscadc_phys_base = res->start;
   204		tscadc->regmap = devm_regmap_init_mmio(&pdev->dev,
   205						       tscadc->tscadc_base,
   206						       &tscadc_regmap_config);
   207		if (IS_ERR(tscadc->regmap)) {
   208			dev_err(&pdev->dev, "regmap init failed\n");
   209			return PTR_ERR(tscadc->regmap);
   210		}
   211	
   212		spin_lock_init(&tscadc->reg_lock);
   213		init_waitqueue_head(&tscadc->reg_se_wait);
   214	
   215		pm_runtime_enable(&pdev->dev);
   216		pm_runtime_get_sync(&pdev->dev);
   217	
   218		/*
   219		 * The TSC_ADC_Subsystem has 2 clock domains: OCP_CLK and ADC_CLK.
   220		 * ADCs produce a 12-bit sample every 15 ADC_CLK cycles.
   221		 * am33xx ADCs expect to capture 200ksps.
   222		 * am47xx ADCs expect to capture 867ksps.
   223		 * We need ADC clocks respectively running at 3MHz and 13MHz.
   224		 * These frequencies are valid since TSC_ADC_SS controller design
   225		 * assumes the OCP clock is at least 6x faster than the ADC clock.
   226		 */
   227		clk = devm_clk_get(&pdev->dev, NULL);
   228		if (IS_ERR(clk)) {
   229			dev_err(&pdev->dev, "failed to get fck\n");
   230			err = PTR_ERR(clk);
   231			goto err_disable_clk;
   232		}
   233	
   234		tscadc->clk_div = (clk_get_rate(clk) / tscadc->data->target_clk_rate) - 1;
   235		regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
   236	
   237		/*
   238		 * Set the control register bits. tscadc->ctrl stores the configuration
   239		 * of the CTRL register but not the subsystem enable bit which must be
   240		 * added manually when timely.
   241		 */
   242		tscadc->ctrl = CNTRLREG_STEPID;
   243		if (ti_adc_with_touchscreen(tscadc)) {
   244			tscadc->ctrl |= CNTRLREG_TSC_STEPCONFIGWRT;
   245			if (use_tsc) {
   246				tscadc->ctrl |= CNTRLREG_TSC_ENB;
   247				if (tscmag_wires == 5)
   248					tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
   249				else
   250					tscadc->ctrl |= CNTRLREG_TSC_4WIRE;
   251			}
   252		} else {
   253			tscadc->ctrl |= CNTRLREG_MAG_PREAMP_PWRDOWN |
   254					CNTRLREG_MAG_PREAMP_BYPASS;
   255		}
   256		regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
   257	
   258		tscadc_idle_config(tscadc);
   259	
   260		/* Enable the TSC module enable bit */
   261		regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB);
   262	
   263		/* TSC or MAG Cell */
   264		if (tscmag_wires > 0) {
   265			cell = &tscadc->cells[cell_idx++];
   266			cell->name = tscadc->data->secondary_feature_name;
   267			cell->of_compatible = tscadc->data->secondary_feature_compatible;
   268			cell->platform_data = &tscadc;
   269			cell->pdata_size = sizeof(tscadc);
   270		}
   271	
   272		/* ADC Cell */
   273		if (adc_channels > 0) {
   274			cell = &tscadc->cells[cell_idx++];
   275			cell->name = tscadc->data->adc_feature_name;
   276			cell->of_compatible = tscadc->data->adc_feature_compatible;
   277			cell->platform_data = &tscadc;
   278			cell->pdata_size = sizeof(tscadc);
   279		}
   280	
   281		err = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
   282				      tscadc->cells, cell_idx, NULL, 0, NULL);
   283		if (err < 0)
   284			goto err_disable_clk;
   285	
   286		platform_set_drvdata(pdev, tscadc);
   287		return 0;
   288	
   289	err_disable_clk:
   290		pm_runtime_put_sync(&pdev->dev);
   291		pm_runtime_disable(&pdev->dev);
   292	
   293		return err;
   294	}
   295	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux