From 1df2598dfebdd1df5bb81c5c8d52fb311c49a7bb Mon Sep 17 00:00:00 2001 From: Balaji Rao Date: Thu, 20 Nov 2008 19:46:51 +0000 Subject: remove_pcf50633_voltage_rails_and_friends.patch 1. Removes pmu_voltage_rails stuff and replaces it with regulator_init_data[] 2. Removes voltage_ldoX and other /sys attributes. 3. Introduces s3c2410_pm_begin method to call regulator_suspend_prepare() --- drivers/i2c/chips/pcf50633.c | 322 ------------------------------------------- 1 file changed, 322 deletions(-) (limited to 'drivers/i2c') diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c index 87f7a844ee4..60b8b1d2764 100644 --- a/drivers/i2c/chips/pcf50633.c +++ b/drivers/i2c/chips/pcf50633.c @@ -215,200 +215,6 @@ static u_int16_t adc_read_result(struct pcf50633_data *pcf) return ret; } - - - -/*********************************************************************** - * Voltage / ADC - ***********************************************************************/ - -static u_int8_t auto_voltage(unsigned int millivolts) -{ - if (millivolts < 1800) - return 0; - if (millivolts > 3800) - return 0xff; - - millivolts -= 625; - return millivolts/25; -} - -static unsigned int auto_2voltage(u_int8_t bits) -{ - if (bits < 0x2f) - return 0; - return 625 + (bits * 25); -} - -static u_int8_t down_voltage(unsigned int millivolts) -{ - if (millivolts < 625) - return 0; - else if (millivolts > 3000) - return 0xff; - - millivolts -= 625; - return millivolts/25; -} - -static unsigned int down_2voltage(u_int8_t bits) -{ - return 625 + (bits*25); -} - -static u_int8_t ldo_voltage(unsigned int millivolts) -{ - if (millivolts < 900) - return 0; - else if (millivolts > 3600) - return 0x1f; - - millivolts -= 900; - return millivolts/100; -} - -static unsigned int ldo_2voltage(u_int8_t bits) -{ - bits &= 0x1f; - return 900 + (bits * 100); -} - -static const u_int8_t regulator_registers[__NUM_PCF50633_REGULATORS] = { - [PCF50633_REGULATOR_AUTO] = PCF50633_REG_AUTOOUT, - [PCF50633_REGULATOR_DOWN1] = PCF50633_REG_DOWN1OUT, - [PCF50633_REGULATOR_DOWN2] = PCF50633_REG_DOWN2OUT, - [PCF50633_REGULATOR_MEMLDO] = PCF50633_REG_MEMLDOOUT, - [PCF50633_REGULATOR_LDO1] = PCF50633_REG_LDO1OUT, - [PCF50633_REGULATOR_LDO2] = PCF50633_REG_LDO2OUT, - [PCF50633_REGULATOR_LDO3] = PCF50633_REG_LDO3OUT, - [PCF50633_REGULATOR_LDO4] = PCF50633_REG_LDO4OUT, - [PCF50633_REGULATOR_LDO5] = PCF50633_REG_LDO5OUT, - [PCF50633_REGULATOR_LDO6] = PCF50633_REG_LDO6OUT, - [PCF50633_REGULATOR_HCLDO] = PCF50633_REG_HCLDOOUT, -}; - -int pcf50633_onoff_set(struct pcf50633_data *pcf, - enum pcf50633_regulator_id reg, int on) -{ - u_int8_t addr; - - if (reg >= __NUM_PCF50633_REGULATORS) - return -EINVAL; - - /* the *ENA register is always one after the *OUT register */ - addr = regulator_registers[reg] + 1; - - if (on == 0) - pcf50633_reg_set_bit_mask(pcf, addr, PCF50633_REGULATOR_ON, 0); - else - pcf50633_reg_set_bit_mask(pcf, addr, PCF50633_REGULATOR_ON, - PCF50633_REGULATOR_ON); - - return 0; -} -EXPORT_SYMBOL_GPL(pcf50633_onoff_set); - -int pcf50633_onoff_get(struct pcf50633_data *pcf, - enum pcf50633_regulator_id reg) -{ - u_int8_t val, addr; - - if (reg >= __NUM_PCF50633_REGULATORS) - return -EINVAL; - - /* the *ENA register is always one after the *OUT register */ - addr = regulator_registers[reg] + 1; - val = pcf50633_reg_read(pcf, addr) & PCF50633_REGULATOR_ON; - - return val; -} -EXPORT_SYMBOL_GPL(pcf50633_onoff_get); - -int pcf50633_voltage_set(struct pcf50633_data *pcf, - enum pcf50633_regulator_id reg, - unsigned int millivolts) -{ - u_int8_t volt_bits; - u_int8_t regnr; - - DEBUGP("pcf=%p, reg=%d, mvolts=%d\n", pcf, reg, millivolts); - - if (reg >= __NUM_PCF50633_REGULATORS) - return -EINVAL; - - regnr = regulator_registers[reg]; - - if (millivolts > pcf->pdata->rails[reg].voltage.max) - return -EINVAL; - - switch (reg) { - case PCF50633_REGULATOR_AUTO: - volt_bits = auto_voltage(millivolts); - break; - case PCF50633_REGULATOR_DOWN1: - volt_bits = down_voltage(millivolts); - break; - case PCF50633_REGULATOR_DOWN2: - volt_bits = down_voltage(millivolts); - break; - case PCF50633_REGULATOR_LDO1: - case PCF50633_REGULATOR_LDO2: - case PCF50633_REGULATOR_LDO3: - case PCF50633_REGULATOR_LDO4: - case PCF50633_REGULATOR_LDO5: - case PCF50633_REGULATOR_LDO6: - case PCF50633_REGULATOR_HCLDO: - volt_bits = ldo_voltage(millivolts); - DEBUGP("ldo_voltage(0x%x)=%u\n", millivolts, volt_bits); - break; - default: - return -EINVAL; - } - - return pcf50633_reg_write(pcf, regnr, volt_bits); -} -EXPORT_SYMBOL_GPL(pcf50633_voltage_set); - -unsigned int pcf50633_voltage_get(struct pcf50633_data *pcf, - enum pcf50633_regulator_id reg) -{ - u_int8_t volt_bits; - u_int8_t regnr; - unsigned int rc = 0; - - if (reg >= __NUM_PCF50633_REGULATORS) - return -EINVAL; - - regnr = regulator_registers[reg]; - volt_bits = pcf50633_reg_read(pcf, regnr); - - switch (reg) { - case PCF50633_REGULATOR_AUTO: - rc = auto_2voltage(volt_bits); - break; - case PCF50633_REGULATOR_DOWN1: - rc = down_2voltage(volt_bits); - break; - case PCF50633_REGULATOR_DOWN2: - rc = down_2voltage(volt_bits); - break; - case PCF50633_REGULATOR_LDO1: - case PCF50633_REGULATOR_LDO2: - case PCF50633_REGULATOR_LDO3: - case PCF50633_REGULATOR_LDO4: - case PCF50633_REGULATOR_LDO5: - case PCF50633_REGULATOR_LDO6: - case PCF50633_REGULATOR_HCLDO: - rc = ldo_2voltage(volt_bits); - break; - default: - return -EINVAL; - } - - return rc; -} -EXPORT_SYMBOL_GPL(pcf50633_voltage_get); - /* go into 'STANDBY' mode, i.e. power off the main CPU and peripherals */ void pcf50633_go_standby(struct pcf50633_data *pcf) { @@ -1278,97 +1084,6 @@ static ssize_t show_battvolt(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR(battvolt, S_IRUGO | S_IWUSR, show_battvolt, NULL); -static int reg_id_by_name(const char *name) -{ - int reg_id; - - if (!strcmp(name, "voltage_auto")) - reg_id = PCF50633_REGULATOR_AUTO; - else if (!strcmp(name, "voltage_down1")) - reg_id = PCF50633_REGULATOR_DOWN1; - else if (!strcmp(name, "voltage_down2")) - reg_id = PCF50633_REGULATOR_DOWN2; - else if (!strcmp(name, "voltage_memldo")) - reg_id = PCF50633_REGULATOR_MEMLDO; - else if (!strcmp(name, "voltage_ldo1")) - reg_id = PCF50633_REGULATOR_LDO1; - else if (!strcmp(name, "voltage_ldo2")) - reg_id = PCF50633_REGULATOR_LDO2; - else if (!strcmp(name, "voltage_ldo3")) - reg_id = PCF50633_REGULATOR_LDO3; - else if (!strcmp(name, "voltage_ldo4")) - reg_id = PCF50633_REGULATOR_LDO4; - else if (!strcmp(name, "voltage_ldo5")) - reg_id = PCF50633_REGULATOR_LDO5; - else if (!strcmp(name, "voltage_ldo6")) - reg_id = PCF50633_REGULATOR_LDO6; - else if (!strcmp(name, "voltage_hcldo")) - reg_id = PCF50633_REGULATOR_HCLDO; - else - reg_id = -1; - - return reg_id; -} - -static ssize_t show_vreg(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct pcf50633_data *pcf = i2c_get_clientdata(client); - unsigned int reg_id; - - reg_id = reg_id_by_name(attr->attr.name); - if (reg_id < 0) - return 0; - - if (pcf50633_onoff_get(pcf, reg_id) > 0) - return sprintf(buf, "%u\n", pcf50633_voltage_get(pcf, reg_id)); - else - return strlcpy(buf, "0\n", PAGE_SIZE); -} - -static ssize_t set_vreg(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct pcf50633_data *pcf = i2c_get_clientdata(client); - unsigned long mvolts = simple_strtoul(buf, NULL, 10); - unsigned int reg_id; - - reg_id = reg_id_by_name(attr->attr.name); - if (reg_id < 0) - return -EIO; - - DEBUGP("attempting to set %s(%d) to %lu mvolts\n", attr->attr.name, - reg_id, mvolts); - - if (mvolts == 0) { - pcf50633_onoff_set(pcf, reg_id, 0); - } else { - if (pcf50633_voltage_set(pcf, reg_id, mvolts) < 0) { - dev_warn(dev, "refusing to set %s(%d) to %lu mvolts " - "(max=%u)\n", attr->attr.name, reg_id, mvolts, - pcf->pdata->rails[reg_id].voltage.max); - return -EINVAL; - } - pcf50633_onoff_set(pcf, reg_id, 1); - } - - return count; -} - -static DEVICE_ATTR(voltage_auto, S_IRUGO | S_IWUSR, show_vreg, set_vreg); -static DEVICE_ATTR(voltage_down1, S_IRUGO | S_IWUSR, show_vreg, set_vreg); -static DEVICE_ATTR(voltage_down2, S_IRUGO | S_IWUSR, show_vreg, set_vreg); -static DEVICE_ATTR(voltage_memldo, S_IRUGO | S_IWUSR, show_vreg, set_vreg); -static DEVICE_ATTR(voltage_ldo1, S_IRUGO | S_IWUSR, show_vreg, set_vreg); -static DEVICE_ATTR(voltage_ldo2, S_IRUGO | S_IWUSR, show_vreg, set_vreg); -static DEVICE_ATTR(voltage_ldo3, S_IRUGO | S_IWUSR, show_vreg, set_vreg); -static DEVICE_ATTR(voltage_ldo4, S_IRUGO | S_IWUSR, show_vreg, set_vreg); -static DEVICE_ATTR(voltage_ldo5, S_IRUGO | S_IWUSR, show_vreg, set_vreg); -static DEVICE_ATTR(voltage_ldo6, S_IRUGO | S_IWUSR, show_vreg, set_vreg); -static DEVICE_ATTR(voltage_hcldo, S_IRUGO | S_IWUSR, show_vreg, set_vreg); - /*********************************************************************** * Charger Control ***********************************************************************/ @@ -1929,17 +1644,6 @@ static DEVICE_ATTR(dump_regs, 0400, show_dump_regs, NULL); * CARE! This table is modified at runtime! */ static struct attribute *pcf_sysfs_entries[] = { - &dev_attr_voltage_auto.attr, - &dev_attr_voltage_down1.attr, - &dev_attr_voltage_down2.attr, - &dev_attr_voltage_memldo.attr, - &dev_attr_voltage_ldo1.attr, - &dev_attr_voltage_ldo2.attr, - &dev_attr_voltage_ldo3.attr, - &dev_attr_voltage_ldo4.attr, - &dev_attr_voltage_ldo5.attr, - &dev_attr_voltage_ldo6.attr, - &dev_attr_voltage_hcldo.attr, &dev_attr_charger_type.attr, &dev_attr_force_usb_limit_dangerous.attr, &dev_attr_charger_adc.attr, @@ -2099,10 +1803,6 @@ static int pcf50633_probe(struct i2c_client *client, const struct i2c_device_id for (i = 0; i < __NUM_PCF50633_REGULATORS; i++) { struct platform_device *pdev; - /* Reject regulators not used by anyone */ - if (pdata->reg_init_data[i].num_consumer_supplies == 0) - continue; - pdev = kzalloc(sizeof(*pdev), GFP_KERNEL); /* FIXME : Handle failure */ @@ -2283,28 +1983,6 @@ static int pcf50633_suspend(struct device *dev, pm_message_t state) &pcf->standby_regs.ldo[0]); if (ret != sizeof(pcf->standby_regs.ldo)) dev_err(dev, "Failed to save LDO levels and enables :-(\n"); - - /* switch off power supplies that are not needed during suspend */ - for (i = 0; i < __NUM_PCF50633_REGULATORS; i++) { - if ((pcf->pdata->rails[i].flags & PMU_VRAIL_F_SUSPEND_ON)) - continue; - - /* we can save ourselves the read part of a read-modify-write - * here because we captured all these already - */ - if (i < 4) - tmp = pcf->standby_regs.misc[i * 4 + 1]; - else - tmp = pcf->standby_regs.ldo[(i - 4) * 2 + 1]; - - dev_dbg(dev, "disabling reg %s by setting ENA %d to 0x%02X\n", - pcf->pdata->rails[i].name, - regulator_registers[i] + 1, tmp & 0xfe); - - /* associated enable is always +1 from OUT reg */ - __reg_write(pcf, regulator_registers[i] + 1, tmp & 0xfe); - } - /* set interrupt masks so only those sources we want to wake * us are able to */ -- cgit v1.2.3