Commit 993a1242 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev
Browse files

fixed a kp when w/o 10389

parent 7235a848
Loading
Loading
Loading
Loading
+42 −19
Original line number Diff line number Diff line
@@ -1207,6 +1207,8 @@ static int elphel393_pwr_probe(struct platform_device *pdev)
	struct i2c_client *ltc3589_client;
	struct elphel393_pwr_data_t *clientdata = NULL;

	struct gpio_desc *desc;

	shutdown_dev = &pdev->dev;

	dev_info(&pdev->dev,"Probing elphel393-pwr\n");
@@ -1228,10 +1230,16 @@ static int elphel393_pwr_probe(struct platform_device *pdev)
	/* locate GPIO chips by i2c address */
    for (i=0;i<3;i++){
    	chip = gpiochip_find(&clientdata->chip_i2c_addr[i], i2c_addr_gpiochip_match);
    	if (chip!=NULL) {
    		base[i]=chip->base;
    		dev_dbg(&pdev->dev,"Found gpio_chip with i2c_addr=0x%02x, label=%s, base=0x%x\n",clientdata->chip_i2c_addr[i],chip->label,base[i]);
    	}else{
    		base[i]=NULL;
    	}
    }
    for (i=0;i<ARRAY_SIZE(pwr_gpio);i++) if (pwr_gpio[i].label){

    for (i=0;i<ARRAY_SIZE(pwr_gpio);i++){
    	if (base[i>>3]!=NULL) if (pwr_gpio[i].label){
    		clientdata->pwr_gpio[i].label=pwr_gpio[i].label;
    	    clientdata->pwr_gpio[i].pin=base[i>>3]+(i & 7);

@@ -1249,6 +1257,19 @@ static int elphel393_pwr_probe(struct platform_device *pdev)
    	    	return rc;
    	    } else {
    	    	dev_dbg(&pdev->dev,"Confirmed request GPIO[%d] with label %s\n",clientdata->pwr_gpio[i].pin,clientdata->pwr_gpio[i].label);
    	    }

			//now try to read and update the structure

			//gpiod_direction_output_raw(gpio_to_desc(gpio), value);

			//desc = gpio_to_desc(base[i>>3]+(i & 7));
			//rc = gpiod_get_direction(desc);
			//pr_info("the %d direction is %d\n",i,rc);

			//clientdata->ltc3489_dev=find_device_by_i2c_addr(clientdata->chip_i2c_addr[i>>3]);
			//ltc3589_client = to_i2c_client(clientdata->ltc3489_dev);
			//pr_info("read %d from i2c: %d\n",i,ltc3589_read_field(ltc3589_client, 0x3));
    	}
    }

@@ -1270,9 +1291,11 @@ static int elphel393_pwr_probe(struct platform_device *pdev)
	 */
	pm_power_off = shutdown;

	if (base[2]!=NULL){
		//turn off PCA9571
		gpio_10389_ctrl(&pdev->dev, 0xf0f);
		gpio_10389_ctrl(&pdev->dev, 0xf00);
	}

	return 0;
}