Merge branches 'ib-from-asoc-3.16', 'ib-from-pm-3.16', 'ib-from-regulator-3.16', 'ib-mfd-gpio-3.16' and 'ib-mfd-mmc-memstick-3.16', tags 'ib-mfd-extcon-3.16', 'ib-mfd-omap-3.16' and 'ib-mfd-regulator-3.16' into ibs-for-mfd-merged
···228228stage. Just pass the values to this function, and the unsigned int229229index returns the number of the frequency table entry which contains230230the frequency the CPU shall be set to.231231+232232+The following macros can be used as iterators over cpufreq_frequency_table:233233+234234+cpufreq_for_each_entry(pos, table) - iterates over all entries of frequency235235+table.236236+237237+cpufreq-for_each_valid_entry(pos, table) - iterates over all entries,238238+excluding CPUFREQ_ENTRY_INVALID frequencies.239239+Use arguments "pos" - a cpufreq_frequency_table * as a loop cursor and240240+"table" - the cpufreq_frequency_table * you want to iterate over.241241+242242+For example:243243+244244+ struct cpufreq_frequency_table *pos, *driver_freq_table;245245+246246+ cpufreq_for_each_entry(pos, driver_freq_table) {247247+ /* Do something with pos */248248+ pos->frequency = ...249249+ }
+3
Documentation/devicetree/bindings/mfd/mc13xxx.txt
···1010- fsl,mc13xxx-uses-touch : Indicate the touchscreen controller is being used11111212Sub-nodes:1313+- codec: Contain the Audio Codec node.1414+ - adc-port: Contain PMIC SSI port number used for ADC.1515+ - dac-port: Contain PMIC SSI port number used for DAC.1316- leds : Contain the led nodes and initial register values in property1417 "led-control". Number of register depends of used IC, for MC13783 is 6,1518 for MC13892 is 4, for MC34708 is 1. See datasheet for bits definitions of
+5-4
arch/arm/mach-davinci/da850.c
···1092109210931093static int da850_round_armrate(struct clk *clk, unsigned long rate)10941094{10951095- int i, ret = 0, diff;10951095+ int ret = 0, diff;10961096 unsigned int best = (unsigned int) -1;10971097 struct cpufreq_frequency_table *table = cpufreq_info.freq_table;10981098+ struct cpufreq_frequency_table *pos;1098109910991100 rate /= 1000; /* convert to kHz */1100110111011101- for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {11021102- diff = table[i].frequency - rate;11021102+ cpufreq_for_each_entry(pos, table) {11031103+ diff = pos->frequency - rate;11031104 if (diff < 0)11041105 diff = -diff;1105110611061107 if (diff < best) {11071108 best = diff;11081108- ret = table[i].frequency;11091109+ ret = pos->frequency;11091110 }11101111 }11111112
-60
arch/arm/mach-omap2/omap_twl.c
···46464747static bool is_offset_valid;4848static u8 smps_offset;4949-/*5050- * Flag to ensure Smartreflex bit in TWL5151- * being cleared in board file is not overwritten.5252- */5353-static bool __initdata twl_sr_enable_autoinit;54495555-#define TWL4030_DCDC_GLOBAL_CFG 0x065650#define REG_SMPS_OFFSET 0xE05757-#define SMARTREFLEX_ENABLE BIT(3)58515952static unsigned long twl4030_vsel_to_uv(const u8 vsel)6053{···244251 if (!cpu_is_omap34xx())245252 return -ENODEV;246253247247- /*248248- * The smartreflex bit on twl4030 specifies if the setting of voltage249249- * is done over the I2C_SR path. Since this setting is independent of250250- * the actual usage of smartreflex AVS module, we enable TWL SR bit251251- * by default irrespective of whether smartreflex AVS module is enabled252252- * on the OMAP side or not. This is because without this bit enabled,253253- * the voltage scaling through vp forceupdate/bypass mechanism of254254- * voltage scaling will not function on TWL over I2C_SR.255255- */256256- if (!twl_sr_enable_autoinit)257257- omap3_twl_set_sr_bit(true);258258-259254 voltdm = voltdm_lookup("mpu_iva");260255 omap_voltage_register_pmic(voltdm, &omap3_mpu_pmic);261256···251270 omap_voltage_register_pmic(voltdm, &omap3_core_pmic);252271253272 return 0;254254-}255255-256256-/**257257- * omap3_twl_set_sr_bit() - Set/Clear SR bit on TWL258258- * @enable: enable SR mode in twl or not259259- *260260- * If 'enable' is true, enables Smartreflex bit on TWL 4030 to make sure261261- * voltage scaling through OMAP SR works. Else, the smartreflex bit262262- * on twl4030 is cleared as there are platforms which use OMAP3 and T2 but263263- * use Synchronized Scaling Hardware Strategy (ENABLE_VMODE=1) and Direct264264- * Strategy Software Scaling Mode (ENABLE_VMODE=0), for setting the voltages,265265- * in those scenarios this bit is to be cleared (enable = false).266266- *267267- * Returns 0 on success, error is returned if I2C read/write fails.268268- */269269-int __init omap3_twl_set_sr_bit(bool enable)270270-{271271- u8 temp;272272- int ret;273273- if (twl_sr_enable_autoinit)274274- pr_warning("%s: unexpected multiple calls\n", __func__);275275-276276- ret = twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &temp,277277- TWL4030_DCDC_GLOBAL_CFG);278278- if (ret)279279- goto err;280280-281281- if (enable)282282- temp |= SMARTREFLEX_ENABLE;283283- else284284- temp &= ~SMARTREFLEX_ENABLE;285285-286286- ret = twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, temp,287287- TWL4030_DCDC_GLOBAL_CFG);288288- if (!ret) {289289- twl_sr_enable_autoinit = true;290290- return 0;291291- }292292-err:293293- pr_err("%s: Error access to TWL4030 (%d)\n", __func__, ret);294294- return ret;295273}
+4-5
drivers/cpufreq/acpi-cpufreq.c
···213213214214static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)215215{216216- int i;216216+ struct cpufreq_frequency_table *pos;217217 struct acpi_processor_performance *perf;218218219219 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)···223223224224 perf = data->acpi_data;225225226226- for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {227227- if (msr == perf->states[data->freq_table[i].driver_data].status)228228- return data->freq_table[i].frequency;229229- }226226+ cpufreq_for_each_entry(pos, data->freq_table)227227+ if (msr == perf->states[pos->driver_data].status)228228+ return pos->frequency;230229 return data->freq_table[0].frequency;231230}232231
+8-8
drivers/cpufreq/arm_big_little.c
···226226/* get the minimum frequency in the cpufreq_frequency_table */227227static inline u32 get_table_min(struct cpufreq_frequency_table *table)228228{229229- int i;229229+ struct cpufreq_frequency_table *pos;230230 uint32_t min_freq = ~0;231231- for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++)232232- if (table[i].frequency < min_freq)233233- min_freq = table[i].frequency;231231+ cpufreq_for_each_entry(pos, table)232232+ if (pos->frequency < min_freq)233233+ min_freq = pos->frequency;234234 return min_freq;235235}236236237237/* get the maximum frequency in the cpufreq_frequency_table */238238static inline u32 get_table_max(struct cpufreq_frequency_table *table)239239{240240- int i;240240+ struct cpufreq_frequency_table *pos;241241 uint32_t max_freq = 0;242242- for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++)243243- if (table[i].frequency > max_freq)244244- max_freq = table[i].frequency;242242+ cpufreq_for_each_entry(pos, table)243243+ if (pos->frequency > max_freq)244244+ max_freq = pos->frequency;245245 return max_freq;246246}247247
+11
drivers/cpufreq/cpufreq.c
···237237}238238EXPORT_SYMBOL_GPL(cpufreq_cpu_put);239239240240+bool cpufreq_next_valid(struct cpufreq_frequency_table **pos)241241+{242242+ while ((*pos)->frequency != CPUFREQ_TABLE_END)243243+ if ((*pos)->frequency != CPUFREQ_ENTRY_INVALID)244244+ return true;245245+ else246246+ (*pos)++;247247+ return false;248248+}249249+EXPORT_SYMBOL_GPL(cpufreq_next_valid);250250+240251/*********************************************************************241252 * EXTERNALLY AFFECTING FREQUENCY CHANGES *242253 *********************************************************************/
+8-16
drivers/cpufreq/cpufreq_stats.c
···182182183183static int __cpufreq_stats_create_table(struct cpufreq_policy *policy)184184{185185- unsigned int i, j, count = 0, ret = 0;185185+ unsigned int i, count = 0, ret = 0;186186 struct cpufreq_stats *stat;187187 unsigned int alloc_size;188188 unsigned int cpu = policy->cpu;189189- struct cpufreq_frequency_table *table;189189+ struct cpufreq_frequency_table *pos, *table;190190191191 table = cpufreq_frequency_get_table(cpu);192192 if (unlikely(!table))···205205 stat->cpu = cpu;206206 per_cpu(cpufreq_stats_table, cpu) = stat;207207208208- for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {209209- unsigned int freq = table[i].frequency;210210- if (freq == CPUFREQ_ENTRY_INVALID)211211- continue;208208+ cpufreq_for_each_valid_entry(pos, table)212209 count++;213213- }214210215211 alloc_size = count * sizeof(int) + count * sizeof(u64);216212···224228#ifdef CONFIG_CPU_FREQ_STAT_DETAILS225229 stat->trans_table = stat->freq_table + count;226230#endif227227- j = 0;228228- for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {229229- unsigned int freq = table[i].frequency;230230- if (freq == CPUFREQ_ENTRY_INVALID)231231- continue;232232- if (freq_table_get_index(stat, freq) == -1)233233- stat->freq_table[j++] = freq;234234- }235235- stat->state_num = j;231231+ i = 0;232232+ cpufreq_for_each_valid_entry(pos, table)233233+ if (freq_table_get_index(stat, pos->frequency) == -1)234234+ stat->freq_table[i++] = pos->frequency;235235+ stat->state_num = i;236236 spin_lock(&cpufreq_stats_lock);237237 stat->last_time = get_jiffies_64();238238 stat->last_index = freq_table_get_index(stat, policy->cur);
+3-5
drivers/cpufreq/dbx500-cpufreq.c
···45454646static int dbx500_cpufreq_probe(struct platform_device *pdev)4747{4848- int i = 0;4848+ struct cpufreq_frequency_table *pos;49495050 freq_table = dev_get_platdata(&pdev->dev);5151 if (!freq_table) {···6060 }61616262 pr_info("dbx500-cpufreq: Available frequencies:\n");6363- while (freq_table[i].frequency != CPUFREQ_TABLE_END) {6464- pr_info(" %d Mhz\n", freq_table[i].frequency/1000);6565- i++;6666- }6363+ cpufreq_for_each_entry(pos, freq_table)6464+ pr_info(" %d Mhz\n", pos->frequency / 1000);67656866 return cpufreq_register_driver(&dbx500_cpufreq_driver);6967}
+4-5
drivers/cpufreq/elanfreq.c
···147147static int elanfreq_cpu_init(struct cpufreq_policy *policy)148148{149149 struct cpuinfo_x86 *c = &cpu_data(0);150150- unsigned int i;150150+ struct cpufreq_frequency_table *pos;151151152152 /* capability check */153153 if ((c->x86_vendor != X86_VENDOR_AMD) ||···159159 max_freq = elanfreq_get_cpu_frequency(0);160160161161 /* table init */162162- for (i = 0; (elanfreq_table[i].frequency != CPUFREQ_TABLE_END); i++) {163163- if (elanfreq_table[i].frequency > max_freq)164164- elanfreq_table[i].frequency = CPUFREQ_ENTRY_INVALID;165165- }162162+ cpufreq_for_each_entry(pos, elanfreq_table)163163+ if (pos->frequency > max_freq)164164+ pos->frequency = CPUFREQ_ENTRY_INVALID;166165167166 /* cpuinfo and default policy values */168167 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
+5-6
drivers/cpufreq/exynos-cpufreq.c
···2929static int exynos_cpufreq_get_index(unsigned int freq)3030{3131 struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;3232- int index;3232+ struct cpufreq_frequency_table *pos;33333434- for (index = 0;3535- freq_table[index].frequency != CPUFREQ_TABLE_END; index++)3636- if (freq_table[index].frequency == freq)3434+ cpufreq_for_each_entry(pos, freq_table)3535+ if (pos->frequency == freq)3736 break;38373939- if (freq_table[index].frequency == CPUFREQ_TABLE_END)3838+ if (pos->frequency == CPUFREQ_TABLE_END)4039 return -EINVAL;41404242- return index;4141+ return pos - freq_table;4342}44434544static int exynos_cpufreq_scale(unsigned int target_freq)
+15-15
drivers/cpufreq/exynos5440-cpufreq.c
···114114115115static int init_div_table(void)116116{117117- struct cpufreq_frequency_table *freq_tbl = dvfs_info->freq_table;117117+ struct cpufreq_frequency_table *pos, *freq_tbl = dvfs_info->freq_table;118118 unsigned int tmp, clk_div, ema_div, freq, volt_id;119119- int i = 0;120119 struct dev_pm_opp *opp;121120122121 rcu_read_lock();123123- for (i = 0; freq_tbl[i].frequency != CPUFREQ_TABLE_END; i++) {124124-122122+ cpufreq_for_each_entry(pos, freq_tbl) {125123 opp = dev_pm_opp_find_freq_exact(dvfs_info->dev,126126- freq_tbl[i].frequency * 1000, true);124124+ pos->frequency * 1000, true);127125 if (IS_ERR(opp)) {128126 rcu_read_unlock();129127 dev_err(dvfs_info->dev,130128 "failed to find valid OPP for %u KHZ\n",131131- freq_tbl[i].frequency);129129+ pos->frequency);132130 return PTR_ERR(opp);133131 }134132135135- freq = freq_tbl[i].frequency / 1000; /* In MHZ */133133+ freq = pos->frequency / 1000; /* In MHZ */136134 clk_div = ((freq / CPU_DIV_FREQ_MAX) & P0_7_CPUCLKDEV_MASK)137135 << P0_7_CPUCLKDEV_SHIFT;138136 clk_div |= ((freq / CPU_ATB_FREQ_MAX) & P0_7_ATBCLKDEV_MASK)···155157 tmp = (clk_div | ema_div | (volt_id << P0_7_VDD_SHIFT)156158 | ((freq / FREQ_UNIT) << P0_7_FREQ_SHIFT));157159158158- __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 * i);160160+ __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 *161161+ (pos - freq_tbl));159162 }160163161164 rcu_read_unlock();···165166166167static void exynos_enable_dvfs(unsigned int cur_frequency)167168{168168- unsigned int tmp, i, cpu;169169+ unsigned int tmp, cpu;169170 struct cpufreq_frequency_table *freq_table = dvfs_info->freq_table;171171+ struct cpufreq_frequency_table *pos;170172 /* Disable DVFS */171173 __raw_writel(0, dvfs_info->base + XMU_DVFS_CTRL);172174···182182 __raw_writel(tmp, dvfs_info->base + XMU_PMUIRQEN);183183184184 /* Set initial performance index */185185- for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++)186186- if (freq_table[i].frequency == cur_frequency)185185+ cpufreq_for_each_entry(pos, freq_table)186186+ if (pos->frequency == cur_frequency)187187 break;188188189189- if (freq_table[i].frequency == CPUFREQ_TABLE_END) {189189+ if (pos->frequency == CPUFREQ_TABLE_END) {190190 dev_crit(dvfs_info->dev, "Boot up frequency not supported\n");191191 /* Assign the highest frequency */192192- i = 0;193193- cur_frequency = freq_table[i].frequency;192192+ pos = freq_table;193193+ cur_frequency = pos->frequency;194194 }195195196196 dev_info(dvfs_info->dev, "Setting dvfs initial frequency = %uKHZ",···199199 for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++) {200200 tmp = __raw_readl(dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4);201201 tmp &= ~(P_VALUE_MASK << C0_3_PSTATE_NEW_SHIFT);202202- tmp |= (i << C0_3_PSTATE_NEW_SHIFT);202202+ tmp |= ((pos - freq_table) << C0_3_PSTATE_NEW_SHIFT);203203 __raw_writel(tmp, dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4);204204 }205205
+25-31
drivers/cpufreq/freq_table.c
···2121int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,2222 struct cpufreq_frequency_table *table)2323{2424+ struct cpufreq_frequency_table *pos;2425 unsigned int min_freq = ~0;2526 unsigned int max_freq = 0;2626- unsigned int i;2727+ unsigned int freq;27282828- for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {2929- unsigned int freq = table[i].frequency;3030- if (freq == CPUFREQ_ENTRY_INVALID) {3131- pr_debug("table entry %u is invalid, skipping\n", i);2929+ cpufreq_for_each_valid_entry(pos, table) {3030+ freq = pos->frequency;32313333- continue;3434- }3532 if (!cpufreq_boost_enabled()3636- && (table[i].flags & CPUFREQ_BOOST_FREQ))3333+ && (pos->flags & CPUFREQ_BOOST_FREQ))3734 continue;38353939- pr_debug("table entry %u: %u kHz\n", i, freq);3636+ pr_debug("table entry %u: %u kHz\n", (int)(pos - table), freq);4037 if (freq < min_freq)4138 min_freq = freq;4239 if (freq > max_freq)···5457int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,5558 struct cpufreq_frequency_table *table)5659{5757- unsigned int next_larger = ~0, freq, i = 0;6060+ struct cpufreq_frequency_table *pos;6161+ unsigned int freq, next_larger = ~0;5862 bool found = false;59636064 pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n",···63656466 cpufreq_verify_within_cpu_limits(policy);65676666- for (; freq = table[i].frequency, freq != CPUFREQ_TABLE_END; i++) {6767- if (freq == CPUFREQ_ENTRY_INVALID)6868- continue;6868+ cpufreq_for_each_valid_entry(pos, table) {6969+ freq = pos->frequency;7070+6971 if ((freq >= policy->min) && (freq <= policy->max)) {7072 found = true;7173 break;···116118 .driver_data = ~0,117119 .frequency = 0,118120 };119119- unsigned int i;121121+ struct cpufreq_frequency_table *pos;122122+ unsigned int freq, i = 0;120123121124 pr_debug("request for target %u kHz (relation: %u) for cpu %u\n",122125 target_freq, relation, policy->cpu);···131132 break;132133 }133134134134- for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {135135- unsigned int freq = table[i].frequency;136136- if (freq == CPUFREQ_ENTRY_INVALID)137137- continue;135135+ cpufreq_for_each_valid_entry(pos, table) {136136+ freq = pos->frequency;137137+138138+ i = pos - table;138139 if ((freq < policy->min) || (freq > policy->max))139140 continue;140141 switch (relation) {···183184int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy,184185 unsigned int freq)185186{186186- struct cpufreq_frequency_table *table;187187- int i;187187+ struct cpufreq_frequency_table *pos, *table;188188189189 table = cpufreq_frequency_get_table(policy->cpu);190190 if (unlikely(!table)) {···191193 return -ENOENT;192194 }193195194194- for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {195195- if (table[i].frequency == freq)196196- return i;197197- }196196+ cpufreq_for_each_valid_entry(pos, table)197197+ if (pos->frequency == freq)198198+ return pos - table;198199199200 return -EINVAL;200201}···205208static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf,206209 bool show_boost)207210{208208- unsigned int i = 0;209211 ssize_t count = 0;210210- struct cpufreq_frequency_table *table = policy->freq_table;212212+ struct cpufreq_frequency_table *pos, *table = policy->freq_table;211213212214 if (!table)213215 return -ENODEV;214216215215- for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {216216- if (table[i].frequency == CPUFREQ_ENTRY_INVALID)217217- continue;217217+ cpufreq_for_each_valid_entry(pos, table) {218218 /*219219 * show_boost = true and driver_data = BOOST freq220220 * display BOOST freqs···223229 * show_boost = false and driver_data != BOOST freq224230 * display NON BOOST freqs225231 */226226- if (show_boost ^ (table[i].flags & CPUFREQ_BOOST_FREQ))232232+ if (show_boost ^ (pos->flags & CPUFREQ_BOOST_FREQ))227233 continue;228234229229- count += sprintf(&buf[count], "%d ", table[i].frequency);235235+ count += sprintf(&buf[count], "%d ", pos->frequency);230236 }231237 count += sprintf(&buf[count], "\n");232238
···136136137137static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)138138{139139+ struct cpufreq_frequency_table *pos;139140 const u32 *max_freqp;140141 u32 max_freq;141141- int i, cur_astate;142142+ int cur_astate;142143 struct resource res;143144 struct device_node *cpu, *dn;144145 int err = -ENODEV;···198197 pr_debug("initializing frequency table\n");199198200199 /* initialize frequency table */201201- for (i=0; pas_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) {202202- pas_freqs[i].frequency =203203- get_astate_freq(pas_freqs[i].driver_data) * 100000;204204- pr_debug("%d: %d\n", i, pas_freqs[i].frequency);200200+ cpufreq_for_each_entry(pos, pas_freqs) {201201+ pos->frequency = get_astate_freq(pos->driver_data) * 100000;202202+ pr_debug("%d: %d\n", (int)(pos - pas_freqs), pos->frequency);205203 }206204207205 cur_astate = get_cur_astate(policy->cpu);
+7-7
drivers/cpufreq/powernow-k6.c
···151151152152static int powernow_k6_cpu_init(struct cpufreq_policy *policy)153153{154154+ struct cpufreq_frequency_table *pos;154155 unsigned int i, f;155156 unsigned khz;156157···169168 }170169 }171170 if (param_max_multiplier) {172172- for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {173173- if (clock_ratio[i].driver_data == param_max_multiplier) {171171+ cpufreq_for_each_entry(pos, clock_ratio)172172+ if (pos->driver_data == param_max_multiplier) {174173 max_multiplier = param_max_multiplier;175174 goto have_max_multiplier;176175 }177177- }178176 printk(KERN_ERR "powernow-k6: invalid max_multiplier parameter, valid parameters 20, 30, 35, 40, 45, 50, 55, 60\n");179177 return -EINVAL;180178 }···201201 param_busfreq = busfreq * 10;202202203203 /* table init */204204- for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {205205- f = clock_ratio[i].driver_data;204204+ cpufreq_for_each_entry(pos, clock_ratio) {205205+ f = pos->driver_data;206206 if (f > max_multiplier)207207- clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID;207207+ pos->frequency = CPUFREQ_ENTRY_INVALID;208208 else209209- clock_ratio[i].frequency = busfreq * f;209209+ pos->frequency = busfreq * f;210210 }211211212212 /* cpuinfo and default policy values */
+5-4
drivers/cpufreq/ppc_cbe_cpufreq.c
···67676868static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)6969{7070+ struct cpufreq_frequency_table *pos;7071 const u32 *max_freqp;7172 u32 max_freq;7272- int i, cur_pmode;7373+ int cur_pmode;7374 struct device_node *cpu;74757576 cpu = of_get_cpu_node(policy->cpu, NULL);···103102 pr_debug("initializing frequency table\n");104103105104 /* initialize frequency table */106106- for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) {107107- cbe_freqs[i].frequency = max_freq / cbe_freqs[i].driver_data;108108- pr_debug("%d: %d\n", i, cbe_freqs[i].frequency);105105+ cpufreq_for_each_entry(pos, cbe_freqs) {106106+ pos->frequency = max_freq / pos->driver_data;107107+ pr_debug("%d: %d\n", (int)(pos - cbe_freqs), pos->frequency);109108 }110109111110 /* if DEBUG is enabled set_pmode() measures the latency
+17-23
drivers/cpufreq/s3c2416-cpufreq.c
···266266static void __init s3c2416_cpufreq_cfg_regulator(struct s3c2416_data *s3c_freq)267267{268268 int count, v, i, found;269269- struct cpufreq_frequency_table *freq;269269+ struct cpufreq_frequency_table *pos;270270 struct s3c2416_dvfs *dvfs;271271272272 count = regulator_count_voltages(s3c_freq->vddarm);···275275 return;276276 }277277278278- freq = s3c_freq->freq_table;279279- while (count > 0 && freq->frequency != CPUFREQ_TABLE_END) {280280- if (freq->frequency == CPUFREQ_ENTRY_INVALID)281281- continue;278278+ if (!count)279279+ goto out;282280283283- dvfs = &s3c2416_dvfs_table[freq->driver_data];281281+ cpufreq_for_each_valid_entry(pos, s3c_freq->freq_table) {282282+ dvfs = &s3c2416_dvfs_table[pos->driver_data];284283 found = 0;285284286285 /* Check only the min-voltage, more is always ok on S3C2416 */···291292292293 if (!found) {293294 pr_debug("cpufreq: %dkHz unsupported by regulator\n",294294- freq->frequency);295295- freq->frequency = CPUFREQ_ENTRY_INVALID;295295+ pos->frequency);296296+ pos->frequency = CPUFREQ_ENTRY_INVALID;296297 }297297-298298- freq++;299298 }300299300300+out:301301 /* Guessed */302302 s3c_freq->regulator_latency = 1 * 1000 * 1000;303303}···336338static int __init s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy)337339{338340 struct s3c2416_data *s3c_freq = &s3c2416_cpufreq;339339- struct cpufreq_frequency_table *freq;341341+ struct cpufreq_frequency_table *pos;340342 struct clk *msysclk;341343 unsigned long rate;342344 int ret;···425427 s3c_freq->regulator_latency = 0;426428#endif427429428428- freq = s3c_freq->freq_table;429429- while (freq->frequency != CPUFREQ_TABLE_END) {430430+ cpufreq_for_each_entry(pos, s3c_freq->freq_table) {430431 /* special handling for dvs mode */431431- if (freq->driver_data == 0) {432432+ if (pos->driver_data == 0) {432433 if (!s3c_freq->hclk) {433434 pr_debug("cpufreq: %dkHz unsupported as it would need unavailable dvs mode\n",434434- freq->frequency);435435- freq->frequency = CPUFREQ_ENTRY_INVALID;435435+ pos->frequency);436436+ pos->frequency = CPUFREQ_ENTRY_INVALID;436437 } else {437437- freq++;438438 continue;439439 }440440 }441441442442 /* Check for frequencies we can generate */443443 rate = clk_round_rate(s3c_freq->armdiv,444444- freq->frequency * 1000);444444+ pos->frequency * 1000);445445 rate /= 1000;446446- if (rate != freq->frequency) {446446+ if (rate != pos->frequency) {447447 pr_debug("cpufreq: %dkHz unsupported by clock (clk_round_rate return %lu)\n",448448- freq->frequency, rate);449449- freq->frequency = CPUFREQ_ENTRY_INVALID;448448+ pos->frequency, rate);449449+ pos->frequency = CPUFREQ_ENTRY_INVALID;450450 }451451-452452- freq++;453451 }454452455453 /* Datasheet says PLL stabalisation time must be at least 300us,
+5-10
drivers/cpufreq/s3c64xx-cpufreq.c
···118118 pr_err("Unable to check supported voltages\n");119119 }120120121121- freq = s3c64xx_freq_table;122122- while (count > 0 && freq->frequency != CPUFREQ_TABLE_END) {123123- if (freq->frequency == CPUFREQ_ENTRY_INVALID)124124- continue;121121+ if (!count)122122+ goto out;125123124124+ cpufreq_for_each_valid_entry(freq, s3c64xx_freq_table) {126125 dvfs = &s3c64xx_dvfs_table[freq->driver_data];127126 found = 0;128127···136137 freq->frequency);137138 freq->frequency = CPUFREQ_ENTRY_INVALID;138139 }139139-140140- freq++;141140 }142141142142+out:143143 /* Guess based on having to do an I2C/SPI write; in future we144144 * will be able to query the regulator performance here. */145145 regulator_latency = 1 * 1000 * 1000;···177179 }178180#endif179181180180- freq = s3c64xx_freq_table;181181- while (freq->frequency != CPUFREQ_TABLE_END) {182182+ cpufreq_for_each_entry(freq, s3c64xx_freq_table) {182183 unsigned long r;183184184185 /* Check for frequencies we can generate */···193196 * frequency is the maximum we can support. */194197 if (!vddarm && freq->frequency > clk_get_rate(policy->clk) / 1000)195198 freq->frequency = CPUFREQ_ENTRY_INVALID;196196-197197- freq++;198199 }199200200201 /* Datasheet says PLL stabalisation time (if we were to use
+2-2
drivers/extcon/Kconfig
···2828 Say Y here to enable extcon device driver based on ADC values.29293030config EXTCON_MAX145773131- tristate "MAX14577 EXTCON Support"3131+ tristate "MAX14577/77836 EXTCON Support"3232 depends on MFD_MAX145773333 select IRQ_DOMAIN3434 select REGMAP_I2C3535 help3636 If you say yes here you get support for the MUIC device of3737- Maxim MAX14577 PMIC. The MAX14577 MUIC is a USB port accessory3737+ Maxim MAX14577/77836. The MAX14577/77836 MUIC is a USB port accessory3838 detector and switch.39394040config EXTCON_MAX77693
+128-48
drivers/extcon/extcon-max14577.c
···11/*22- * extcon-max14577.c - MAX14577 extcon driver to support MAX14577 MUIC22+ * extcon-max14577.c - MAX14577/77836 extcon driver to support MUIC33 *44- * Copyright (C) 2013 Samsung Electrnoics44+ * Copyright (C) 2013,2014 Samsung Electrnoics55 * Chanwoo Choi <cw00.choi@samsung.com>66+ * Krzysztof Kozlowski <k.kozlowski@samsung.com>67 *78 * This program is free software; you can redistribute it and/or modify89 * it under the terms of the GNU General Public License as published by···2524#include <linux/mfd/max14577-private.h>2625#include <linux/extcon.h>27262828-#define DEV_NAME "max14577-muic"2927#define DELAY_MS_DEFAULT 17000 /* unit: millisecond */30283129enum max14577_muic_adc_debounce_time {···4040 MAX14577_MUIC_STATUS_END,4141};42424343+/**4444+ * struct max14577_muic_irq4545+ * @irq: the index of irq list of MUIC device.4646+ * @name: the name of irq.4747+ * @virq: the virtual irq to use irq domain4848+ */4949+struct max14577_muic_irq {5050+ unsigned int irq;5151+ const char *name;5252+ unsigned int virq;5353+};5454+5555+static struct max14577_muic_irq max14577_muic_irqs[] = {5656+ { MAX14577_IRQ_INT1_ADC, "muic-ADC" },5757+ { MAX14577_IRQ_INT1_ADCLOW, "muic-ADCLOW" },5858+ { MAX14577_IRQ_INT1_ADCERR, "muic-ADCError" },5959+ { MAX14577_IRQ_INT2_CHGTYP, "muic-CHGTYP" },6060+ { MAX14577_IRQ_INT2_CHGDETRUN, "muic-CHGDETRUN" },6161+ { MAX14577_IRQ_INT2_DCDTMR, "muic-DCDTMR" },6262+ { MAX14577_IRQ_INT2_DBCHG, "muic-DBCHG" },6363+ { MAX14577_IRQ_INT2_VBVOLT, "muic-VBVOLT" },6464+};6565+6666+static struct max14577_muic_irq max77836_muic_irqs[] = {6767+ { MAX14577_IRQ_INT1_ADC, "muic-ADC" },6868+ { MAX14577_IRQ_INT1_ADCLOW, "muic-ADCLOW" },6969+ { MAX14577_IRQ_INT1_ADCERR, "muic-ADCError" },7070+ { MAX77836_IRQ_INT1_ADC1K, "muic-ADC1K" },7171+ { MAX14577_IRQ_INT2_CHGTYP, "muic-CHGTYP" },7272+ { MAX14577_IRQ_INT2_CHGDETRUN, "muic-CHGDETRUN" },7373+ { MAX14577_IRQ_INT2_DCDTMR, "muic-DCDTMR" },7474+ { MAX14577_IRQ_INT2_DBCHG, "muic-DBCHG" },7575+ { MAX14577_IRQ_INT2_VBVOLT, "muic-VBVOLT" },7676+ { MAX77836_IRQ_INT2_VIDRM, "muic-VIDRM" },7777+};7878+4379struct max14577_muic_info {4480 struct device *dev;4581 struct max14577 *max14577;···8448 int prev_chg_type;8549 u8 status[MAX14577_MUIC_STATUS_END];86505151+ struct max14577_muic_irq *muic_irqs;5252+ unsigned int muic_irqs_num;8753 bool irq_adc;8854 bool irq_chg;8955 struct work_struct irq_work;···11072enum max14577_muic_cable_group {11173 MAX14577_CABLE_GROUP_ADC = 0,11274 MAX14577_CABLE_GROUP_CHG,113113-};114114-115115-/**116116- * struct max14577_muic_irq117117- * @irq: the index of irq list of MUIC device.118118- * @name: the name of irq.119119- * @virq: the virtual irq to use irq domain120120- */121121-struct max14577_muic_irq {122122- unsigned int irq;123123- const char *name;124124- unsigned int virq;125125-};126126-127127-static struct max14577_muic_irq muic_irqs[] = {128128- { MAX14577_IRQ_INT1_ADC, "muic-ADC" },129129- { MAX14577_IRQ_INT1_ADCLOW, "muic-ADCLOW" },130130- { MAX14577_IRQ_INT1_ADCERR, "muic-ADCError" },131131- { MAX14577_IRQ_INT2_CHGTYP, "muic-CHGTYP" },132132- { MAX14577_IRQ_INT2_CHGDETRUN, "muic-CHGDETRUN" },133133- { MAX14577_IRQ_INT2_DCDTMR, "muic-DCDTMR" },134134- { MAX14577_IRQ_INT2_DBCHG, "muic-DBCHG" },135135- { MAX14577_IRQ_INT2_VBVOLT, "muic-VBVOLT" },13675};1377613877/* Define supported accessory type */···543528 return;544529}545530546546-static irqreturn_t max14577_muic_irq_handler(int irq, void *data)531531+/*532532+ * Sets irq_adc or irq_chg in max14577_muic_info and returns 1.533533+ * Returns 0 if irq_type does not match registered IRQ for this device type.534534+ */535535+static int max14577_parse_irq(struct max14577_muic_info *info, int irq_type)547536{548548- struct max14577_muic_info *info = data;549549- int i, irq_type = -1;550550-551551- /*552552- * We may be called multiple times for different nested IRQ-s.553553- * Including changes in INT1_ADC and INT2_CGHTYP at once.554554- * However we only need to know whether it was ADC, charger555555- * or both interrupts so decode IRQ and turn on proper flags.556556- */557557- for (i = 0; i < ARRAY_SIZE(muic_irqs); i++)558558- if (irq == muic_irqs[i].virq)559559- irq_type = muic_irqs[i].irq;560560-561537 switch (irq_type) {562538 case MAX14577_IRQ_INT1_ADC:563539 case MAX14577_IRQ_INT1_ADCLOW:···556550 /* Handle all of accessory except for557551 type of charger accessory */558552 info->irq_adc = true;559559- break;553553+ return 1;560554 case MAX14577_IRQ_INT2_CHGTYP:561555 case MAX14577_IRQ_INT2_CHGDETRUN:562556 case MAX14577_IRQ_INT2_DCDTMR:···564558 case MAX14577_IRQ_INT2_VBVOLT:565559 /* Handle charger accessory */566560 info->irq_chg = true;567567- break;561561+ return 1;568562 default:563563+ return 0;564564+ }565565+}566566+567567+/*568568+ * Sets irq_adc or irq_chg in max14577_muic_info and returns 1.569569+ * Returns 0 if irq_type does not match registered IRQ for this device type.570570+ */571571+static int max77836_parse_irq(struct max14577_muic_info *info, int irq_type)572572+{573573+ /* First check common max14577 interrupts */574574+ if (max14577_parse_irq(info, irq_type))575575+ return 1;576576+577577+ switch (irq_type) {578578+ case MAX77836_IRQ_INT1_ADC1K:579579+ info->irq_adc = true;580580+ return 1;581581+ case MAX77836_IRQ_INT2_VIDRM:582582+ /* Handle charger accessory */583583+ info->irq_chg = true;584584+ return 1;585585+ default:586586+ return 0;587587+ }588588+}589589+590590+static irqreturn_t max14577_muic_irq_handler(int irq, void *data)591591+{592592+ struct max14577_muic_info *info = data;593593+ int i, irq_type = -1;594594+ bool irq_parsed;595595+596596+ /*597597+ * We may be called multiple times for different nested IRQ-s.598598+ * Including changes in INT1_ADC and INT2_CGHTYP at once.599599+ * However we only need to know whether it was ADC, charger600600+ * or both interrupts so decode IRQ and turn on proper flags.601601+ */602602+ for (i = 0; i < info->muic_irqs_num; i++)603603+ if (irq == info->muic_irqs[i].virq)604604+ irq_type = info->muic_irqs[i].irq;605605+606606+ switch (info->max14577->dev_type) {607607+ case MAXIM_DEVICE_TYPE_MAX77836:608608+ irq_parsed = max77836_parse_irq(info, irq_type);609609+ break;610610+ case MAXIM_DEVICE_TYPE_MAX14577:611611+ default:612612+ irq_parsed = max14577_parse_irq(info, irq_type);613613+ break;614614+ }615615+616616+ if (!irq_parsed) {569617 dev_err(info->dev, "muic interrupt: irq %d occurred, skipped\n",570618 irq_type);571619 return IRQ_HANDLED;···704644705645 INIT_WORK(&info->irq_work, max14577_muic_irq_work);706646647647+ switch (max14577->dev_type) {648648+ case MAXIM_DEVICE_TYPE_MAX77836:649649+ info->muic_irqs = max77836_muic_irqs;650650+ info->muic_irqs_num = ARRAY_SIZE(max77836_muic_irqs);651651+ break;652652+ case MAXIM_DEVICE_TYPE_MAX14577:653653+ default:654654+ info->muic_irqs = max14577_muic_irqs;655655+ info->muic_irqs_num = ARRAY_SIZE(max14577_muic_irqs);656656+ }657657+707658 /* Support irq domain for max14577 MUIC device */708708- for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {709709- struct max14577_muic_irq *muic_irq = &muic_irqs[i];659659+ for (i = 0; i < info->muic_irqs_num; i++) {660660+ struct max14577_muic_irq *muic_irq = &info->muic_irqs[i];710661 unsigned int virq = 0;711662712663 virq = regmap_irq_get_virq(max14577->irq_data, muic_irq->irq);···744673 dev_err(&pdev->dev, "failed to allocate memory for extcon\n");745674 return -ENOMEM;746675 }747747- info->edev->name = DEV_NAME;676676+677677+ info->edev->name = dev_name(&pdev->dev);748678 info->edev->supported_cable = max14577_extcon_cable;749679 ret = extcon_dev_register(info->edev);750680 if (ret) {···807735 return 0;808736}809737738738+static const struct platform_device_id max14577_muic_id[] = {739739+ { "max14577-muic", MAXIM_DEVICE_TYPE_MAX14577, },740740+ { "max77836-muic", MAXIM_DEVICE_TYPE_MAX77836, },741741+ { }742742+};743743+MODULE_DEVICE_TABLE(platform, max14577_muic_id);744744+810745static struct platform_driver max14577_muic_driver = {811746 .driver = {812812- .name = DEV_NAME,747747+ .name = "max14577-muic",813748 .owner = THIS_MODULE,814749 },815750 .probe = max14577_muic_probe,816751 .remove = max14577_muic_remove,752752+ .id_table = max14577_muic_id,817753};818754819755module_platform_driver(max14577_muic_driver);820756821821-MODULE_DESCRIPTION("MAXIM 14577 Extcon driver");822822-MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>");757757+MODULE_DESCRIPTION("Maxim 14577/77836 Extcon driver");758758+MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>, Krzysztof Kozlowski <k.kozlowski@samsung.com>");823759MODULE_LICENSE("GPL");824760MODULE_ALIAS("platform:extcon-max14577");
+5-13
drivers/gpio/gpio-stmpe.c
···2323enum { REG_RE, REG_FE, REG_IE };24242525#define CACHE_NR_REGS 32626-#define CACHE_NR_BANKS (STMPE_NR_GPIOS / 8)2626+/* No variant has more than 24 GPIOs */2727+#define CACHE_NR_BANKS (24 / 8)27282829struct stmpe_gpio {2930 struct gpio_chip chip;···3231 struct device *dev;3332 struct mutex irq_lock;3433 struct irq_domain *domain;3535-3636- int irq_base;3734 unsigned norequest_mask;38353936 /* Caches of interrupt control registers for bus_lock */···310311static int stmpe_gpio_irq_init(struct stmpe_gpio *stmpe_gpio,311312 struct device_node *np)312313{313313- int base = 0;314314-315315- if (!np)316316- base = stmpe_gpio->irq_base;317317-318314 stmpe_gpio->domain = irq_domain_add_simple(np,319319- stmpe_gpio->chip.ngpio, base,315315+ stmpe_gpio->chip.ngpio, 0,320316 &stmpe_gpio_irq_simple_ops, stmpe_gpio);321317 if (!stmpe_gpio->domain) {322318 dev_err(stmpe_gpio->dev, "failed to create irqdomain\n");···348354#ifdef CONFIG_OF349355 stmpe_gpio->chip.of_node = np;350356#endif351351- stmpe_gpio->chip.base = pdata ? pdata->gpio_base : -1;357357+ stmpe_gpio->chip.base = -1;352358353359 if (pdata)354360 stmpe_gpio->norequest_mask = pdata->norequest_mask;···356362 of_property_read_u32(np, "st,norequest-mask",357363 &stmpe_gpio->norequest_mask);358364359359- if (irq >= 0)360360- stmpe_gpio->irq_base = stmpe->irq_base + STMPE_INT_GPIO(0);361361- else365365+ if (irq < 0)362366 dev_info(&pdev->dev,363367 "device configured in no-irq mode; "364368 "irqs are not available\n");
+10
drivers/memstick/host/Kconfig
···52525353 To compile this driver as a module, choose M here: the module will5454 be called rtsx_pci_ms.5555+5656+config MEMSTICK_REALTEK_USB5757+ tristate "Realtek USB Memstick Card Interface Driver"5858+ depends on MFD_RTSX_USB5959+ help6060+ Say Y here to include driver code to support Memstick card interface6161+ of Realtek RTS5129/39 series USB card reader6262+6363+ To compile this driver as a module, choose M here: the module will6464+ be called rts5139_ms.
···11+/* Realtek USB Memstick Card Interface driver22+ *33+ * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.44+ *55+ * This program is free software; you can redistribute it and/or modify it66+ * under the terms of the GNU General Public License version 277+ * as published by the Free Software Foundation.88+ *99+ * This program is distributed in the hope that it will be useful, but1010+ * WITHOUT ANY WARRANTY; without even the implied warranty of1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU1212+ * General Public License for more details.1313+ *1414+ * You should have received a copy of the GNU General Public License along1515+ * with this program; if not, see <http://www.gnu.org/licenses/>.1616+ *1717+ * Author:1818+ * Roger Tseng <rogerable@realtek.com>1919+ */2020+2121+#include <linux/module.h>2222+#include <linux/highmem.h>2323+#include <linux/delay.h>2424+#include <linux/platform_device.h>2525+#include <linux/workqueue.h>2626+#include <linux/memstick.h>2727+#include <linux/kthread.h>2828+#include <linux/mfd/rtsx_usb.h>2929+#include <linux/pm_runtime.h>3030+#include <linux/mutex.h>3131+#include <linux/sched.h>3232+#include <linux/completion.h>3333+#include <asm/unaligned.h>3434+3535+struct rtsx_usb_ms {3636+ struct platform_device *pdev;3737+ struct rtsx_ucr *ucr;3838+ struct memstick_host *msh;3939+ struct memstick_request *req;4040+4141+ struct mutex host_mutex;4242+ struct work_struct handle_req;4343+4444+ struct task_struct *detect_ms;4545+ struct completion detect_ms_exit;4646+4747+ u8 ssc_depth;4848+ unsigned int clock;4949+ int power_mode;5050+ unsigned char ifmode;5151+ bool eject;5252+};5353+5454+static inline struct device *ms_dev(struct rtsx_usb_ms *host)5555+{5656+ return &(host->pdev->dev);5757+}5858+5959+static inline void ms_clear_error(struct rtsx_usb_ms *host)6060+{6161+ struct rtsx_ucr *ucr = host->ucr;6262+ rtsx_usb_ep0_write_register(ucr, CARD_STOP,6363+ MS_STOP | MS_CLR_ERR,6464+ MS_STOP | MS_CLR_ERR);6565+6666+ rtsx_usb_clear_dma_err(ucr);6767+ rtsx_usb_clear_fsm_err(ucr);6868+}6969+7070+#ifdef DEBUG7171+7272+static void ms_print_debug_regs(struct rtsx_usb_ms *host)7373+{7474+ struct rtsx_ucr *ucr = host->ucr;7575+ u16 i;7676+ u8 *ptr;7777+7878+ /* Print MS host internal registers */7979+ rtsx_usb_init_cmd(ucr);8080+8181+ /* MS_CFG to MS_INT_REG */8282+ for (i = 0xFD40; i <= 0xFD44; i++)8383+ rtsx_usb_add_cmd(ucr, READ_REG_CMD, i, 0, 0);8484+8585+ /* CARD_SHARE_MODE to CARD_GPIO */8686+ for (i = 0xFD51; i <= 0xFD56; i++)8787+ rtsx_usb_add_cmd(ucr, READ_REG_CMD, i, 0, 0);8888+8989+ /* CARD_PULL_CTLx */9090+ for (i = 0xFD60; i <= 0xFD65; i++)9191+ rtsx_usb_add_cmd(ucr, READ_REG_CMD, i, 0, 0);9292+9393+ /* CARD_DATA_SOURCE, CARD_SELECT, CARD_CLK_EN, CARD_PWR_CTL */9494+ rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_DATA_SOURCE, 0, 0);9595+ rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_SELECT, 0, 0);9696+ rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_CLK_EN, 0, 0);9797+ rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_PWR_CTL, 0, 0);9898+9999+ rtsx_usb_send_cmd(ucr, MODE_CR, 100);100100+ rtsx_usb_get_rsp(ucr, 21, 100);101101+102102+ ptr = ucr->rsp_buf;103103+ for (i = 0xFD40; i <= 0xFD44; i++)104104+ dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));105105+ for (i = 0xFD51; i <= 0xFD56; i++)106106+ dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));107107+ for (i = 0xFD60; i <= 0xFD65; i++)108108+ dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));109109+110110+ dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_DATA_SOURCE, *(ptr++));111111+ dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_SELECT, *(ptr++));112112+ dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_CLK_EN, *(ptr++));113113+ dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_PWR_CTL, *(ptr++));114114+}115115+116116+#else117117+118118+static void ms_print_debug_regs(struct rtsx_usb_ms *host)119119+{120120+}121121+122122+#endif123123+124124+static int ms_pull_ctl_disable_lqfp48(struct rtsx_ucr *ucr)125125+{126126+ rtsx_usb_init_cmd(ucr);127127+128128+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x55);129129+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55);130130+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95);131131+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55);132132+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55);133133+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5);134134+135135+ return rtsx_usb_send_cmd(ucr, MODE_C, 100);136136+}137137+138138+static int ms_pull_ctl_disable_qfn24(struct rtsx_ucr *ucr)139139+{140140+ rtsx_usb_init_cmd(ucr);141141+142142+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x65);143143+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55);144144+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95);145145+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55);146146+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x56);147147+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x59);148148+149149+ return rtsx_usb_send_cmd(ucr, MODE_C, 100);150150+}151151+152152+static int ms_pull_ctl_enable_lqfp48(struct rtsx_ucr *ucr)153153+{154154+ rtsx_usb_init_cmd(ucr);155155+156156+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x55);157157+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55);158158+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95);159159+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55);160160+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55);161161+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5);162162+163163+ return rtsx_usb_send_cmd(ucr, MODE_C, 100);164164+}165165+166166+static int ms_pull_ctl_enable_qfn24(struct rtsx_ucr *ucr)167167+{168168+ rtsx_usb_init_cmd(ucr);169169+170170+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x65);171171+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55);172172+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95);173173+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55);174174+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55);175175+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x59);176176+177177+ return rtsx_usb_send_cmd(ucr, MODE_C, 100);178178+}179179+180180+static int ms_power_on(struct rtsx_usb_ms *host)181181+{182182+ struct rtsx_ucr *ucr = host->ucr;183183+ int err;184184+185185+ dev_dbg(ms_dev(host), "%s\n", __func__);186186+187187+ rtsx_usb_init_cmd(ucr);188188+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_SELECT, 0x07, MS_MOD_SEL);189189+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_SHARE_MODE,190190+ CARD_SHARE_MASK, CARD_SHARE_MS);191191+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_CLK_EN,192192+ MS_CLK_EN, MS_CLK_EN);193193+ err = rtsx_usb_send_cmd(ucr, MODE_C, 100);194194+ if (err < 0)195195+ return err;196196+197197+ if (CHECK_PKG(ucr, LQFP48))198198+ err = ms_pull_ctl_enable_lqfp48(ucr);199199+ else200200+ err = ms_pull_ctl_enable_qfn24(ucr);201201+ if (err < 0)202202+ return err;203203+204204+ err = rtsx_usb_write_register(ucr, CARD_PWR_CTL,205205+ POWER_MASK, PARTIAL_POWER_ON);206206+ if (err)207207+ return err;208208+209209+ usleep_range(800, 1000);210210+211211+ rtsx_usb_init_cmd(ucr);212212+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PWR_CTL,213213+ POWER_MASK, POWER_ON);214214+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_OE,215215+ MS_OUTPUT_EN, MS_OUTPUT_EN);216216+217217+ return rtsx_usb_send_cmd(ucr, MODE_C, 100);218218+}219219+220220+static int ms_power_off(struct rtsx_usb_ms *host)221221+{222222+ struct rtsx_ucr *ucr = host->ucr;223223+ int err;224224+225225+ dev_dbg(ms_dev(host), "%s\n", __func__);226226+227227+ rtsx_usb_init_cmd(ucr);228228+229229+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_CLK_EN, MS_CLK_EN, 0);230230+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_OE, MS_OUTPUT_EN, 0);231231+232232+ err = rtsx_usb_send_cmd(ucr, MODE_C, 100);233233+ if (err < 0)234234+ return err;235235+236236+ if (CHECK_PKG(ucr, LQFP48))237237+ return ms_pull_ctl_disable_lqfp48(ucr);238238+239239+ return ms_pull_ctl_disable_qfn24(ucr);240240+}241241+242242+static int ms_transfer_data(struct rtsx_usb_ms *host, unsigned char data_dir,243243+ u8 tpc, u8 cfg, struct scatterlist *sg)244244+{245245+ struct rtsx_ucr *ucr = host->ucr;246246+ int err;247247+ unsigned int length = sg->length;248248+ u16 sec_cnt = (u16)(length / 512);249249+ u8 trans_mode, dma_dir, flag;250250+ unsigned int pipe;251251+ struct memstick_dev *card = host->msh->card;252252+253253+ dev_dbg(ms_dev(host), "%s: tpc = 0x%02x, data_dir = %s, length = %d\n",254254+ __func__, tpc, (data_dir == READ) ? "READ" : "WRITE",255255+ length);256256+257257+ if (data_dir == READ) {258258+ flag = MODE_CDIR;259259+ dma_dir = DMA_DIR_FROM_CARD;260260+ if (card->id.type != MEMSTICK_TYPE_PRO)261261+ trans_mode = MS_TM_NORMAL_READ;262262+ else263263+ trans_mode = MS_TM_AUTO_READ;264264+ pipe = usb_rcvbulkpipe(ucr->pusb_dev, EP_BULK_IN);265265+ } else {266266+ flag = MODE_CDOR;267267+ dma_dir = DMA_DIR_TO_CARD;268268+ if (card->id.type != MEMSTICK_TYPE_PRO)269269+ trans_mode = MS_TM_NORMAL_WRITE;270270+ else271271+ trans_mode = MS_TM_AUTO_WRITE;272272+ pipe = usb_sndbulkpipe(ucr->pusb_dev, EP_BULK_OUT);273273+ }274274+275275+ rtsx_usb_init_cmd(ucr);276276+277277+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_TPC, 0xFF, tpc);278278+ if (card->id.type == MEMSTICK_TYPE_PRO) {279279+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_SECTOR_CNT_H,280280+ 0xFF, (u8)(sec_cnt >> 8));281281+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_SECTOR_CNT_L,282282+ 0xFF, (u8)sec_cnt);283283+ }284284+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg);285285+286286+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MC_DMA_TC3,287287+ 0xFF, (u8)(length >> 24));288288+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MC_DMA_TC2,289289+ 0xFF, (u8)(length >> 16));290290+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MC_DMA_TC1,291291+ 0xFF, (u8)(length >> 8));292292+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MC_DMA_TC0, 0xFF,293293+ (u8)length);294294+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MC_DMA_CTL,295295+ 0x03 | DMA_PACK_SIZE_MASK, dma_dir | DMA_EN | DMA_512);296296+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_DATA_SOURCE,297297+ 0x01, RING_BUFFER);298298+299299+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_TRANSFER,300300+ 0xFF, MS_TRANSFER_START | trans_mode);301301+ rtsx_usb_add_cmd(ucr, CHECK_REG_CMD, MS_TRANSFER,302302+ MS_TRANSFER_END, MS_TRANSFER_END);303303+304304+ err = rtsx_usb_send_cmd(ucr, flag | STAGE_MS_STATUS, 100);305305+ if (err)306306+ return err;307307+308308+ err = rtsx_usb_transfer_data(ucr, pipe, sg, length,309309+ 1, NULL, 10000);310310+ if (err)311311+ goto err_out;312312+313313+ err = rtsx_usb_get_rsp(ucr, 3, 15000);314314+ if (err)315315+ goto err_out;316316+317317+ if (ucr->rsp_buf[0] & MS_TRANSFER_ERR ||318318+ ucr->rsp_buf[1] & (MS_CRC16_ERR | MS_RDY_TIMEOUT)) {319319+ err = -EIO;320320+ goto err_out;321321+ }322322+ return 0;323323+err_out:324324+ ms_clear_error(host);325325+ return err;326326+}327327+328328+static int ms_write_bytes(struct rtsx_usb_ms *host, u8 tpc,329329+ u8 cfg, u8 cnt, u8 *data, u8 *int_reg)330330+{331331+ struct rtsx_ucr *ucr = host->ucr;332332+ int err, i;333333+334334+ dev_dbg(ms_dev(host), "%s: tpc = 0x%02x\n", __func__, tpc);335335+336336+ rtsx_usb_init_cmd(ucr);337337+338338+ for (i = 0; i < cnt; i++)339339+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD,340340+ PPBUF_BASE2 + i, 0xFF, data[i]);341341+342342+ if (cnt % 2)343343+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD,344344+ PPBUF_BASE2 + i, 0xFF, 0xFF);345345+346346+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_TPC, 0xFF, tpc);347347+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_BYTE_CNT, 0xFF, cnt);348348+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg);349349+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_DATA_SOURCE,350350+ 0x01, PINGPONG_BUFFER);351351+352352+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_TRANSFER,353353+ 0xFF, MS_TRANSFER_START | MS_TM_WRITE_BYTES);354354+ rtsx_usb_add_cmd(ucr, CHECK_REG_CMD, MS_TRANSFER,355355+ MS_TRANSFER_END, MS_TRANSFER_END);356356+ rtsx_usb_add_cmd(ucr, READ_REG_CMD, MS_TRANS_CFG, 0, 0);357357+358358+ err = rtsx_usb_send_cmd(ucr, MODE_CR, 100);359359+ if (err)360360+ return err;361361+362362+ err = rtsx_usb_get_rsp(ucr, 2, 5000);363363+ if (err || (ucr->rsp_buf[0] & MS_TRANSFER_ERR)) {364364+ u8 val;365365+366366+ rtsx_usb_ep0_read_register(ucr, MS_TRANS_CFG, &val);367367+ dev_dbg(ms_dev(host), "MS_TRANS_CFG: 0x%02x\n", val);368368+369369+ if (int_reg)370370+ *int_reg = val & 0x0F;371371+372372+ ms_print_debug_regs(host);373373+374374+ ms_clear_error(host);375375+376376+ if (!(tpc & 0x08)) {377377+ if (val & MS_CRC16_ERR)378378+ return -EIO;379379+ } else {380380+ if (!(val & 0x80)) {381381+ if (val & (MS_INT_ERR | MS_INT_CMDNK))382382+ return -EIO;383383+ }384384+ }385385+386386+ return -ETIMEDOUT;387387+ }388388+389389+ if (int_reg)390390+ *int_reg = ucr->rsp_buf[1] & 0x0F;391391+392392+ return 0;393393+}394394+395395+static int ms_read_bytes(struct rtsx_usb_ms *host, u8 tpc,396396+ u8 cfg, u8 cnt, u8 *data, u8 *int_reg)397397+{398398+ struct rtsx_ucr *ucr = host->ucr;399399+ int err, i;400400+ u8 *ptr;401401+402402+ dev_dbg(ms_dev(host), "%s: tpc = 0x%02x\n", __func__, tpc);403403+404404+ rtsx_usb_init_cmd(ucr);405405+406406+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_TPC, 0xFF, tpc);407407+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_BYTE_CNT, 0xFF, cnt);408408+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg);409409+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_DATA_SOURCE,410410+ 0x01, PINGPONG_BUFFER);411411+412412+ rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, MS_TRANSFER,413413+ 0xFF, MS_TRANSFER_START | MS_TM_READ_BYTES);414414+ rtsx_usb_add_cmd(ucr, CHECK_REG_CMD, MS_TRANSFER,415415+ MS_TRANSFER_END, MS_TRANSFER_END);416416+ for (i = 0; i < cnt - 1; i++)417417+ rtsx_usb_add_cmd(ucr, READ_REG_CMD, PPBUF_BASE2 + i, 0, 0);418418+ if (cnt % 2)419419+ rtsx_usb_add_cmd(ucr, READ_REG_CMD, PPBUF_BASE2 + cnt, 0, 0);420420+ else421421+ rtsx_usb_add_cmd(ucr, READ_REG_CMD,422422+ PPBUF_BASE2 + cnt - 1, 0, 0);423423+424424+ rtsx_usb_add_cmd(ucr, READ_REG_CMD, MS_TRANS_CFG, 0, 0);425425+426426+ err = rtsx_usb_send_cmd(ucr, MODE_CR, 100);427427+ if (err)428428+ return err;429429+430430+ err = rtsx_usb_get_rsp(ucr, cnt + 2, 5000);431431+ if (err || (ucr->rsp_buf[0] & MS_TRANSFER_ERR)) {432432+ u8 val;433433+434434+ rtsx_usb_ep0_read_register(ucr, MS_TRANS_CFG, &val);435435+ dev_dbg(ms_dev(host), "MS_TRANS_CFG: 0x%02x\n", val);436436+437437+ if (int_reg && (host->ifmode != MEMSTICK_SERIAL))438438+ *int_reg = val & 0x0F;439439+440440+ ms_print_debug_regs(host);441441+442442+ ms_clear_error(host);443443+444444+ if (!(tpc & 0x08)) {445445+ if (val & MS_CRC16_ERR)446446+ return -EIO;447447+ } else {448448+ if (!(val & 0x80)) {449449+ if (val & (MS_INT_ERR | MS_INT_CMDNK))450450+ return -EIO;451451+ }452452+ }453453+454454+ return -ETIMEDOUT;455455+ }456456+457457+ ptr = ucr->rsp_buf + 1;458458+ for (i = 0; i < cnt; i++)459459+ data[i] = *ptr++;460460+461461+462462+ if (int_reg && (host->ifmode != MEMSTICK_SERIAL))463463+ *int_reg = *ptr & 0x0F;464464+465465+ return 0;466466+}467467+468468+static int rtsx_usb_ms_issue_cmd(struct rtsx_usb_ms *host)469469+{470470+ struct memstick_request *req = host->req;471471+ int err = 0;472472+ u8 cfg = 0, int_reg;473473+474474+ dev_dbg(ms_dev(host), "%s\n", __func__);475475+476476+ if (req->need_card_int) {477477+ if (host->ifmode != MEMSTICK_SERIAL)478478+ cfg = WAIT_INT;479479+ }480480+481481+ if (req->long_data) {482482+ err = ms_transfer_data(host, req->data_dir,483483+ req->tpc, cfg, &(req->sg));484484+ } else {485485+ if (req->data_dir == READ)486486+ err = ms_read_bytes(host, req->tpc, cfg,487487+ req->data_len, req->data, &int_reg);488488+ else489489+ err = ms_write_bytes(host, req->tpc, cfg,490490+ req->data_len, req->data, &int_reg);491491+ }492492+ if (err < 0)493493+ return err;494494+495495+ if (req->need_card_int) {496496+ if (host->ifmode == MEMSTICK_SERIAL) {497497+ err = ms_read_bytes(host, MS_TPC_GET_INT,498498+ NO_WAIT_INT, 1, &req->int_reg, NULL);499499+ if (err < 0)500500+ return err;501501+ } else {502502+503503+ if (int_reg & MS_INT_CMDNK)504504+ req->int_reg |= MEMSTICK_INT_CMDNAK;505505+ if (int_reg & MS_INT_BREQ)506506+ req->int_reg |= MEMSTICK_INT_BREQ;507507+ if (int_reg & MS_INT_ERR)508508+ req->int_reg |= MEMSTICK_INT_ERR;509509+ if (int_reg & MS_INT_CED)510510+ req->int_reg |= MEMSTICK_INT_CED;511511+ }512512+ dev_dbg(ms_dev(host), "int_reg: 0x%02x\n", req->int_reg);513513+ }514514+515515+ return 0;516516+}517517+518518+static void rtsx_usb_ms_handle_req(struct work_struct *work)519519+{520520+ struct rtsx_usb_ms *host = container_of(work,521521+ struct rtsx_usb_ms, handle_req);522522+ struct rtsx_ucr *ucr = host->ucr;523523+ struct memstick_host *msh = host->msh;524524+ int rc;525525+526526+ if (!host->req) {527527+ do {528528+ rc = memstick_next_req(msh, &host->req);529529+ dev_dbg(ms_dev(host), "next req %d\n", rc);530530+531531+ if (!rc) {532532+ mutex_lock(&ucr->dev_mutex);533533+534534+ if (rtsx_usb_card_exclusive_check(ucr,535535+ RTSX_USB_MS_CARD))536536+ host->req->error = -EIO;537537+ else538538+ host->req->error =539539+ rtsx_usb_ms_issue_cmd(host);540540+541541+ mutex_unlock(&ucr->dev_mutex);542542+543543+ dev_dbg(ms_dev(host), "req result %d\n",544544+ host->req->error);545545+ }546546+ } while (!rc);547547+ }548548+549549+}550550+551551+static void rtsx_usb_ms_request(struct memstick_host *msh)552552+{553553+ struct rtsx_usb_ms *host = memstick_priv(msh);554554+555555+ dev_dbg(ms_dev(host), "--> %s\n", __func__);556556+557557+ if (!host->eject)558558+ schedule_work(&host->handle_req);559559+}560560+561561+static int rtsx_usb_ms_set_param(struct memstick_host *msh,562562+ enum memstick_param param, int value)563563+{564564+ struct rtsx_usb_ms *host = memstick_priv(msh);565565+ struct rtsx_ucr *ucr = host->ucr;566566+ unsigned int clock = 0;567567+ u8 ssc_depth = 0;568568+ int err;569569+570570+ dev_dbg(ms_dev(host), "%s: param = %d, value = %d\n",571571+ __func__, param, value);572572+573573+ mutex_lock(&ucr->dev_mutex);574574+575575+ err = rtsx_usb_card_exclusive_check(ucr, RTSX_USB_MS_CARD);576576+ if (err)577577+ goto out;578578+579579+ switch (param) {580580+ case MEMSTICK_POWER:581581+ if (value == host->power_mode)582582+ break;583583+584584+ if (value == MEMSTICK_POWER_ON) {585585+ pm_runtime_get_sync(ms_dev(host));586586+ err = ms_power_on(host);587587+ } else if (value == MEMSTICK_POWER_OFF) {588588+ err = ms_power_off(host);589589+ if (host->msh->card)590590+ pm_runtime_put_noidle(ms_dev(host));591591+ else592592+ pm_runtime_put(ms_dev(host));593593+ } else594594+ err = -EINVAL;595595+ if (!err)596596+ host->power_mode = value;597597+ break;598598+599599+ case MEMSTICK_INTERFACE:600600+ if (value == MEMSTICK_SERIAL) {601601+ clock = 19000000;602602+ ssc_depth = SSC_DEPTH_512K;603603+ err = rtsx_usb_write_register(ucr, MS_CFG, 0x5A,604604+ MS_BUS_WIDTH_1 | PUSH_TIME_DEFAULT);605605+ if (err < 0)606606+ break;607607+ } else if (value == MEMSTICK_PAR4) {608608+ clock = 39000000;609609+ ssc_depth = SSC_DEPTH_1M;610610+611611+ err = rtsx_usb_write_register(ucr, MS_CFG, 0x5A,612612+ MS_BUS_WIDTH_4 | PUSH_TIME_ODD |613613+ MS_NO_CHECK_INT);614614+ if (err < 0)615615+ break;616616+ } else {617617+ err = -EINVAL;618618+ break;619619+ }620620+621621+ err = rtsx_usb_switch_clock(ucr, clock,622622+ ssc_depth, false, true, false);623623+ if (err < 0) {624624+ dev_dbg(ms_dev(host), "switch clock failed\n");625625+ break;626626+ }627627+628628+ host->ssc_depth = ssc_depth;629629+ host->clock = clock;630630+ host->ifmode = value;631631+ break;632632+ default:633633+ err = -EINVAL;634634+ break;635635+ }636636+out:637637+ mutex_unlock(&ucr->dev_mutex);638638+639639+ /* power-on delay */640640+ if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON)641641+ usleep_range(10000, 12000);642642+643643+ dev_dbg(ms_dev(host), "%s: return = %d\n", __func__, err);644644+ return err;645645+}646646+647647+#ifdef CONFIG_PM_SLEEP648648+static int rtsx_usb_ms_suspend(struct device *dev)649649+{650650+ struct rtsx_usb_ms *host = dev_get_drvdata(dev);651651+ struct memstick_host *msh = host->msh;652652+653653+ dev_dbg(ms_dev(host), "--> %s\n", __func__);654654+655655+ memstick_suspend_host(msh);656656+ return 0;657657+}658658+659659+static int rtsx_usb_ms_resume(struct device *dev)660660+{661661+ struct rtsx_usb_ms *host = dev_get_drvdata(dev);662662+ struct memstick_host *msh = host->msh;663663+664664+ dev_dbg(ms_dev(host), "--> %s\n", __func__);665665+666666+ memstick_resume_host(msh);667667+ return 0;668668+}669669+#endif /* CONFIG_PM_SLEEP */670670+671671+/*672672+ * Thread function of ms card slot detection. The thread starts right after673673+ * successful host addition. It stops while the driver removal function sets674674+ * host->eject true.675675+ */676676+static int rtsx_usb_detect_ms_card(void *__host)677677+{678678+ struct rtsx_usb_ms *host = (struct rtsx_usb_ms *)__host;679679+ struct rtsx_ucr *ucr = host->ucr;680680+ u8 val = 0;681681+ int err;682682+683683+ for (;;) {684684+ mutex_lock(&ucr->dev_mutex);685685+686686+ /* Check pending MS card changes */687687+ err = rtsx_usb_read_register(ucr, CARD_INT_PEND, &val);688688+ if (err) {689689+ mutex_unlock(&ucr->dev_mutex);690690+ goto poll_again;691691+ }692692+693693+ /* Clear the pending */694694+ rtsx_usb_write_register(ucr, CARD_INT_PEND,695695+ XD_INT | MS_INT | SD_INT,696696+ XD_INT | MS_INT | SD_INT);697697+698698+ mutex_unlock(&ucr->dev_mutex);699699+700700+ if (val & MS_INT) {701701+ dev_dbg(ms_dev(host), "MS slot change detected\n");702702+ memstick_detect_change(host->msh);703703+ }704704+705705+poll_again:706706+ if (host->eject)707707+ break;708708+709709+ msleep(1000);710710+ }711711+712712+ complete(&host->detect_ms_exit);713713+ return 0;714714+}715715+716716+static int rtsx_usb_ms_drv_probe(struct platform_device *pdev)717717+{718718+ struct memstick_host *msh;719719+ struct rtsx_usb_ms *host;720720+ struct rtsx_ucr *ucr;721721+ int err;722722+723723+ ucr = usb_get_intfdata(to_usb_interface(pdev->dev.parent));724724+ if (!ucr)725725+ return -ENXIO;726726+727727+ dev_dbg(&(pdev->dev),728728+ "Realtek USB Memstick controller found\n");729729+730730+ msh = memstick_alloc_host(sizeof(*host), &pdev->dev);731731+ if (!msh)732732+ return -ENOMEM;733733+734734+ host = memstick_priv(msh);735735+ host->ucr = ucr;736736+ host->msh = msh;737737+ host->pdev = pdev;738738+ host->power_mode = MEMSTICK_POWER_OFF;739739+ platform_set_drvdata(pdev, host);740740+741741+ mutex_init(&host->host_mutex);742742+ INIT_WORK(&host->handle_req, rtsx_usb_ms_handle_req);743743+744744+ init_completion(&host->detect_ms_exit);745745+ host->detect_ms = kthread_create(rtsx_usb_detect_ms_card, host,746746+ "rtsx_usb_ms_%d", pdev->id);747747+ if (IS_ERR(host->detect_ms)) {748748+ dev_dbg(&(pdev->dev),749749+ "Unable to create polling thread.\n");750750+ err = PTR_ERR(host->detect_ms);751751+ goto err_out;752752+ }753753+754754+ msh->request = rtsx_usb_ms_request;755755+ msh->set_param = rtsx_usb_ms_set_param;756756+ msh->caps = MEMSTICK_CAP_PAR4;757757+758758+ pm_runtime_enable(&pdev->dev);759759+ err = memstick_add_host(msh);760760+ if (err)761761+ goto err_out;762762+763763+ wake_up_process(host->detect_ms);764764+ return 0;765765+err_out:766766+ memstick_free_host(msh);767767+ return err;768768+}769769+770770+static int rtsx_usb_ms_drv_remove(struct platform_device *pdev)771771+{772772+ struct rtsx_usb_ms *host = platform_get_drvdata(pdev);773773+ struct memstick_host *msh;774774+ int err;775775+776776+ msh = host->msh;777777+ host->eject = true;778778+ cancel_work_sync(&host->handle_req);779779+780780+ mutex_lock(&host->host_mutex);781781+ if (host->req) {782782+ dev_dbg(&(pdev->dev),783783+ "%s: Controller removed during transfer\n",784784+ dev_name(&msh->dev));785785+ host->req->error = -ENOMEDIUM;786786+ do {787787+ err = memstick_next_req(msh, &host->req);788788+ if (!err)789789+ host->req->error = -ENOMEDIUM;790790+ } while (!err);791791+ }792792+ mutex_unlock(&host->host_mutex);793793+794794+ wait_for_completion(&host->detect_ms_exit);795795+ memstick_remove_host(msh);796796+ memstick_free_host(msh);797797+798798+ /* Balance possible unbalanced usage count799799+ * e.g. unconditional module removal800800+ */801801+ if (pm_runtime_active(ms_dev(host)))802802+ pm_runtime_put(ms_dev(host));803803+804804+ pm_runtime_disable(&pdev->dev);805805+ platform_set_drvdata(pdev, NULL);806806+807807+ dev_dbg(&(pdev->dev),808808+ ": Realtek USB Memstick controller has been removed\n");809809+810810+ return 0;811811+}812812+813813+static SIMPLE_DEV_PM_OPS(rtsx_usb_ms_pm_ops,814814+ rtsx_usb_ms_suspend, rtsx_usb_ms_resume);815815+816816+static struct platform_device_id rtsx_usb_ms_ids[] = {817817+ {818818+ .name = "rtsx_usb_ms",819819+ }, {820820+ /* sentinel */821821+ }822822+};823823+MODULE_DEVICE_TABLE(platform, rtsx_usb_ms_ids);824824+825825+static struct platform_driver rtsx_usb_ms_driver = {826826+ .probe = rtsx_usb_ms_drv_probe,827827+ .remove = rtsx_usb_ms_drv_remove,828828+ .id_table = rtsx_usb_ms_ids,829829+ .driver = {830830+ .owner = THIS_MODULE,831831+ .name = "rtsx_usb_ms",832832+ .pm = &rtsx_usb_ms_pm_ops,833833+ },834834+};835835+module_platform_driver(rtsx_usb_ms_driver);836836+837837+MODULE_LICENSE("GPL v2");838838+MODULE_AUTHOR("Roger Tseng <rogerable@realtek.com>");839839+MODULE_DESCRIPTION("Realtek USB Memstick Card Host Driver");
+4-3
drivers/mfd/Kconfig
···331331 battery-charger under the corresponding menus.332332333333config MFD_MAX14577334334- bool "Maxim Semiconductor MAX14577 MUIC + Charger Support"334334+ bool "Maxim Semiconductor MAX14577/77836 MUIC + Charger Support"335335 depends on I2C=y336336 select MFD_CORE337337 select REGMAP_I2C338338 select REGMAP_IRQ339339 select IRQ_DOMAIN340340 help341341- Say yes here to add support for Maxim Semiconductor MAX14577.342342- This is a Micro-USB IC with Charger controls on chip.341341+ Say yes here to add support for Maxim Semiconductor MAX14577 and342342+ MAX77836 Micro-USB ICs with battery charger.343343 This driver provides common support for accessing the device;344344 additional drivers must be enabled in order to use the functionality345345 of the device.···675675config MFD_STMPE676676 bool "STMicroelectronics STMPE"677677 depends on (I2C=y || SPI_MASTER=y)678678+ depends on OF678679 select MFD_CORE679680 help680681 Support for the STMPE family of I/O Expanders from
+24-17
drivers/mfd/arizona-core.c
···508508}509509EXPORT_SYMBOL_GPL(arizona_of_get_type);510510511511+int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,512512+ bool mandatory)513513+{514514+ int gpio;515515+516516+ gpio = of_get_named_gpio(arizona->dev->of_node, prop, 0);517517+ if (gpio < 0) {518518+ if (mandatory)519519+ dev_err(arizona->dev,520520+ "Mandatory DT gpio %s missing/malformed: %d\n",521521+ prop, gpio);522522+523523+ gpio = 0;524524+ }525525+526526+ return gpio;527527+}528528+EXPORT_SYMBOL_GPL(arizona_of_get_named_gpio);529529+511530static int arizona_of_get_core_pdata(struct arizona *arizona)512531{532532+ struct arizona_pdata *pdata = &arizona->pdata;513533 int ret, i;514534515515- arizona->pdata.reset = of_get_named_gpio(arizona->dev->of_node,516516- "wlf,reset", 0);517517- if (arizona->pdata.reset < 0)518518- arizona->pdata.reset = 0;519519-520520- arizona->pdata.ldoena = of_get_named_gpio(arizona->dev->of_node,521521- "wlf,ldoena", 0);522522- if (arizona->pdata.ldoena < 0)523523- arizona->pdata.ldoena = 0;535535+ pdata->reset = arizona_of_get_named_gpio(arizona, "wlf,reset", true);524536525537 ret = of_property_read_u32_array(arizona->dev->of_node,526538 "wlf,gpio-defaults",···663651 arizona->type);664652 return -EINVAL;665653 }654654+655655+ /* Mark DCVDD as external, LDO1 driver will clear if internal */656656+ arizona->external_dcvdd = true;666657667658 ret = mfd_add_devices(arizona->dev, -1, early_devs,668659 ARRAY_SIZE(early_devs), NULL, 0, NULL);···865850 regmap_write(arizona->regmap, ARIZONA_GPIO1_CTRL + i,866851 arizona->pdata.gpio_defaults[i]);867852 }868868-869869- /*870870- * LDO1 can only be used to supply DCVDD so if it has no871871- * consumers then DCVDD is supplied externally.872872- */873873- if (arizona->pdata.ldo1 &&874874- arizona->pdata.ldo1->num_consumer_supplies == 0)875875- arizona->external_dcvdd = true;876853877854 pm_runtime_set_autosuspend_delay(arizona->dev, 100);878855 pm_runtime_use_autosuspend(arizona->dev);
+8-11
drivers/mfd/db8500-prcmu.c
···1734173417351735static long round_armss_rate(unsigned long rate)17361736{17371737+ struct cpufreq_frequency_table *pos;17371738 long freq = 0;17381738- int i = 0;1739173917401740 /* cpufreq table frequencies is in KHz. */17411741 rate = rate / 1000;1742174217431743 /* Find the corresponding arm opp from the cpufreq table. */17441744- while (db8500_cpufreq_table[i].frequency != CPUFREQ_TABLE_END) {17451745- freq = db8500_cpufreq_table[i].frequency;17441744+ cpufreq_for_each_entry(pos, db8500_cpufreq_table) {17451745+ freq = pos->frequency;17461746 if (freq == rate)17471747 break;17481748- i++;17491748 }1750174917511750 /* Return the last valid value, even if a match was not found. */···1885188618861887static int set_armss_rate(unsigned long rate)18871888{18881888- int i = 0;18891889+ struct cpufreq_frequency_table *pos;1889189018901891 /* cpufreq table frequencies is in KHz. */18911892 rate = rate / 1000;1892189318931894 /* Find the corresponding arm opp from the cpufreq table. */18941894- while (db8500_cpufreq_table[i].frequency != CPUFREQ_TABLE_END) {18951895- if (db8500_cpufreq_table[i].frequency == rate)18951895+ cpufreq_for_each_entry(pos, db8500_cpufreq_table)18961896+ if (pos->frequency == rate)18961897 break;18971897- i++;18981898- }1899189819001900- if (db8500_cpufreq_table[i].frequency != rate)18991899+ if (pos->frequency != rate)19011900 return -EINVAL;1902190119031902 /* Set the new arm opp. */19041904- return db8500_prcmu_set_arm_opp(db8500_cpufreq_table[i].driver_data);19031903+ return db8500_prcmu_set_arm_opp(pos->driver_data);19051904}1906190519071906static int set_plldsi_rate(unsigned long rate)
···673673 if (mc13xxx->flags & MC13XXX_USE_ADC)674674 mc13xxx_add_subdevice(mc13xxx, "%s-adc");675675676676- if (mc13xxx->flags & MC13XXX_USE_CODEC)677677- mc13xxx_add_subdevice_pdata(mc13xxx, "%s-codec",678678- pdata->codec, sizeof(*pdata->codec));676676+ if (mc13xxx->flags & MC13XXX_USE_CODEC) {677677+ if (pdata)678678+ mc13xxx_add_subdevice_pdata(mc13xxx, "%s-codec",679679+ pdata->codec, sizeof(*pdata->codec));680680+ else681681+ mc13xxx_add_subdevice(mc13xxx, "%s-codec");682682+ }679683680684 if (mc13xxx->flags & MC13XXX_USE_RTC)681685 mc13xxx_add_subdevice(mc13xxx, "%s-rtc");
+10-4
drivers/mfd/rtsx_usb.c
···6767 ucr->sg_timer.expires = jiffies + msecs_to_jiffies(timeout);6868 add_timer(&ucr->sg_timer);6969 usb_sg_wait(&ucr->current_sg);7070- del_timer(&ucr->sg_timer);7070+ del_timer_sync(&ucr->sg_timer);71717272 if (act_len)7373 *act_len = ucr->current_sg.bytes;···644644 if (ret)645645 goto out_init_fail;646646647647+ /* initialize USB SG transfer timer */648648+ setup_timer(&ucr->sg_timer, rtsx_usb_sg_timed_out, (unsigned long) ucr);649649+647650 ret = mfd_add_devices(&intf->dev, usb_dev->devnum, rtsx_usb_cells,648651 ARRAY_SIZE(rtsx_usb_cells), NULL, 0, NULL);649652 if (ret)650653 goto out_init_fail;651654652652- /* initialize USB SG transfer timer */653653- init_timer(&ucr->sg_timer);654654- setup_timer(&ucr->sg_timer, rtsx_usb_sg_timed_out, (unsigned long) ucr);655655#ifdef CONFIG_PM656656 intf->needs_remote_wakeup = 1;657657 usb_enable_autosuspend(usb_dev);···687687 dev_dbg(&intf->dev, "%s called with pm message 0x%04u\n",688688 __func__, message.event);689689690690+ /*691691+ * Call to make sure LED is off during suspend to save more power.692692+ * It is NOT a permanent state and could be turned on anytime later.693693+ * Thus no need to call turn_on when resunming.694694+ */690695 mutex_lock(&ucr->dev_mutex);691696 rtsx_usb_turn_off_led(ucr);692697 mutex_unlock(&ucr->dev_mutex);698698+693699 return 0;694700}695701
···2020#include <linux/slab.h>2121#include <linux/mfd/core.h>2222#include <linux/delay.h>2323+#include <linux/regulator/consumer.h>2324#include "stmpe.h"24252526static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks)···606605607606 if (blocks & STMPE_BLOCK_GPIO)608607 mask |= STMPE1601_SYS_CTRL_ENABLE_GPIO;608608+ else609609+ mask &= ~STMPE1601_SYS_CTRL_ENABLE_GPIO;609610610611 if (blocks & STMPE_BLOCK_KEYPAD)611612 mask |= STMPE1601_SYS_CTRL_ENABLE_KPC;613613+ else614614+ mask &= ~STMPE1601_SYS_CTRL_ENABLE_KPC;615615+616616+ if (blocks & STMPE_BLOCK_PWM)617617+ mask |= STMPE1601_SYS_CTRL_ENABLE_SPWM;618618+ else619619+ mask &= ~STMPE1601_SYS_CTRL_ENABLE_SPWM;612620613621 return __stmpe_set_bits(stmpe, STMPE1601_REG_SYS_CTRL, mask,614622 enable ? mask : 0);···996986 int base = 0;997987 int num_irqs = stmpe->variant->num_irqs;998988999999- if (!np)10001000- base = stmpe->irq_base;10011001-1002989 stmpe->domain = irq_domain_add_simple(np, num_irqs, base,1003990 &stmpe_irq_ops, stmpe);1004991 if (!stmpe->domain) {···10741067static int stmpe_add_device(struct stmpe *stmpe, const struct mfd_cell *cell)10751068{10761069 return mfd_add_devices(stmpe->dev, stmpe->pdata->id, cell, 1,10771077- NULL, stmpe->irq_base, stmpe->domain);10701070+ NULL, 0, stmpe->domain);10781071}1079107210801073static int stmpe_devices_init(struct stmpe *stmpe)···11781171 stmpe->dev = ci->dev;11791172 stmpe->client = ci->client;11801173 stmpe->pdata = pdata;11811181- stmpe->irq_base = pdata->irq_base;11821174 stmpe->ci = ci;11831175 stmpe->partnum = partnum;11841176 stmpe->variant = stmpe_variant_info[partnum];11851177 stmpe->regs = stmpe->variant->regs;11861178 stmpe->num_gpios = stmpe->variant->num_gpios;11791179+ stmpe->vcc = devm_regulator_get_optional(ci->dev, "vcc");11801180+ if (!IS_ERR(stmpe->vcc)) {11811181+ ret = regulator_enable(stmpe->vcc);11821182+ if (ret)11831183+ dev_warn(ci->dev, "failed to enable VCC supply\n");11841184+ }11851185+ stmpe->vio = devm_regulator_get_optional(ci->dev, "vio");11861186+ if (!IS_ERR(stmpe->vio)) {11871187+ ret = regulator_enable(stmpe->vio);11881188+ if (ret)11891189+ dev_warn(ci->dev, "failed to enable VIO supply\n");11901190+ }11871191 dev_set_drvdata(stmpe->dev, stmpe);1188119211891193 if (ci->init)···1261124312621244int stmpe_remove(struct stmpe *stmpe)12631245{12461246+ if (!IS_ERR(stmpe->vio))12471247+ regulator_disable(stmpe->vio);12481248+ if (!IS_ERR(stmpe->vcc))12491249+ regulator_disable(stmpe->vcc);12501250+12641251 mfd_remove_devices(stmpe->dev);1265125212661253 return 0;
+1-1
drivers/mfd/stmpe.h
···192192193193#define STMPE1601_SYS_CTRL_ENABLE_GPIO (1 << 3)194194#define STMPE1601_SYS_CTRL_ENABLE_KPC (1 << 1)195195-#define STMPE1601_SYSCON_ENABLE_SPWM (1 << 0)195195+#define STMPE1601_SYS_CTRL_ENABLE_SPWM (1 << 0)196196197197/* The 1601/2403 share the same masks */198198#define STMPE1601_AUTOSLEEP_TIMEOUT_MASK (0x7)
+25-16
drivers/mfd/tps65090.c
···3232#define NUM_INT_REG 23333#define TOTAL_NUM_REG 0x1834343535-/* interrupt status registers */3636-#define TPS65090_INT_STS 0x03737-#define TPS65090_INT_STS2 0x13838-3939-/* interrupt mask registers */4040-#define TPS65090_INT_MSK 0x24141-#define TPS65090_INT_MSK2 0x34242-4335#define TPS65090_INT1_MASK_VAC_STATUS_CHANGE 14436#define TPS65090_INT1_MASK_VSYS_STATUS_CHANGE 24537#define TPS65090_INT1_MASK_BAT_STATUS_CHANGE 3···5664 }5765};58665959-static const struct mfd_cell tps65090s[] = {6060- {6767+enum tps65090_cells {6868+ PMIC = 0,6969+ CHARGER = 1,7070+};7171+7272+static struct mfd_cell tps65090s[] = {7373+ [PMIC] = {6174 .name = "tps65090-pmic",6275 },6363- {7676+ [CHARGER] = {6477 .name = "tps65090-charger",6578 .num_resources = ARRAY_SIZE(charger_resources),6679 .resources = &charger_resources[0],···136139 .irqs = tps65090_irqs,137140 .num_irqs = ARRAY_SIZE(tps65090_irqs),138141 .num_regs = NUM_INT_REG,139139- .status_base = TPS65090_INT_STS,140140- .mask_base = TPS65090_INT_MSK,142142+ .status_base = TPS65090_REG_INTR_STS,143143+ .mask_base = TPS65090_REG_INTR_MASK,141144 .mask_invert = true,142145};143146144147static bool is_volatile_reg(struct device *dev, unsigned int reg)145148{146146- if ((reg == TPS65090_INT_STS) || (reg == TPS65090_INT_STS2))147147- return true;148148- else149149+ /* Nearly all registers have status bits mixed in, except a few */150150+ switch (reg) {151151+ case TPS65090_REG_INTR_MASK:152152+ case TPS65090_REG_INTR_MASK2:153153+ case TPS65090_REG_CG_CTRL0:154154+ case TPS65090_REG_CG_CTRL1:155155+ case TPS65090_REG_CG_CTRL2:156156+ case TPS65090_REG_CG_CTRL3:157157+ case TPS65090_REG_CG_CTRL4:158158+ case TPS65090_REG_CG_CTRL5:149159 return false;160160+ }161161+ return true;150162}151163152164static const struct regmap_config tps65090_regmap_config = {···217211 "IRQ init failed with err: %d\n", ret);218212 return ret;219213 }214214+ } else {215215+ /* Don't tell children they have an IRQ that'll never fire */216216+ tps65090s[CHARGER].num_resources = 0;220217 }221218222219 ret = mfd_add_devices(tps65090->dev, -1, tps65090s,
+4
drivers/mfd/tps6586x.c
···495495 case TPS658623:496496 name = "TPS658623";497497 break;498498+ case TPS658640:499499+ case TPS658640v2:500500+ name = "TPS658640";501501+ break;498502 case TPS658643:499503 name = "TPS658643";500504 break;
+15
drivers/mfd/twl-core.c
···9898#define TWL4030_BASEADD_BACKUP 0x00149999#define TWL4030_BASEADD_INT 0x002E100100#define TWL4030_BASEADD_PM_MASTER 0x0036101101+101102#define TWL4030_BASEADD_PM_RECEIVER 0x005B103103+#define TWL4030_DCDC_GLOBAL_CFG 0x06104104+#define SMARTREFLEX_ENABLE BIT(3)105105+102106#define TWL4030_BASEADD_RTC 0x001C103107#define TWL4030_BASEADD_SECURED_REG 0x0000104108···12081204 * Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface.12091205 * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0,12101206 * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0.12071207+ *12081208+ * Also, always enable SmartReflex bit as that's needed for omaps to12091209+ * to do anything over I2C4 for voltage scaling even if SmartReflex12101210+ * is disabled. Without the SmartReflex bit omap sys_clkreq idle12111211+ * signal will never trigger for retention idle.12111212 */12121213 if (twl_class_is_4030()) {12131214 u8 temp;···12211212 temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \12221213 I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU);12231214 twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);12151215+12161216+ twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &temp,12171217+ TWL4030_DCDC_GLOBAL_CFG);12181218+ temp |= SMARTREFLEX_ENABLE;12191219+ twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, temp,12201220+ TWL4030_DCDC_GLOBAL_CFG);12241221 }1225122212261223 if (node) {
+7
drivers/mmc/host/Kconfig
···694694 help695695 Say Y here to include driver code to support SD/MMC card interface696696 of Realtek PCI-E card reader697697+698698+config MMC_REALTEK_USB699699+ tristate "Realtek USB SD/MMC Card Interface Driver"700700+ depends on MFD_RTSX_USB701701+ help702702+ Say Y here to include driver code to support SD/MMC card interface703703+ of Realtek RTS5129/39 series card reader
···266266 This driver supports LP8788 voltage regulator chip.267267268268config REGULATOR_MAX14577269269- tristate "Maxim 14577 regulator"269269+ tristate "Maxim 14577/77836 regulator"270270 depends on MFD_MAX14577271271 help272272- This driver controls a Maxim 14577 regulator via I2C bus.273273- The regulators include safeout LDO and current regulator 'CHARGER'.272272+ This driver controls a Maxim MAX14577/77836 regulator via I2C bus.273273+ The MAX14577 regulators include safeout LDO and charger current274274+ regulator. The MAX77836 has two additional LDOs.274275275276config REGULATOR_MAX1586276277 tristate "Maxim 1586/1587 voltage regulator"
+57
drivers/regulator/arizona-ldo1.c
···1919#include <linux/platform_device.h>2020#include <linux/regulator/driver.h>2121#include <linux/regulator/machine.h>2222+#include <linux/regulator/of_regulator.h>2223#include <linux/gpio.h>2324#include <linux/slab.h>2425···179178 .num_consumer_supplies = 1,180179};181180181181+static int arizona_ldo1_of_get_pdata(struct arizona *arizona,182182+ struct regulator_config *config)183183+{184184+ struct arizona_pdata *pdata = &arizona->pdata;185185+ struct arizona_ldo1 *ldo1 = config->driver_data;186186+ struct device_node *init_node, *dcvdd_node;187187+ struct regulator_init_data *init_data;188188+189189+ pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true);190190+191191+ init_node = of_get_child_by_name(arizona->dev->of_node, "ldo1");192192+ dcvdd_node = of_parse_phandle(arizona->dev->of_node, "DCVDD-supply", 0);193193+194194+ if (init_node) {195195+ config->of_node = init_node;196196+197197+ init_data = of_get_regulator_init_data(arizona->dev, init_node);198198+199199+ if (init_data) {200200+ init_data->consumer_supplies = &ldo1->supply;201201+ init_data->num_consumer_supplies = 1;202202+203203+ if (dcvdd_node && dcvdd_node != init_node)204204+ arizona->external_dcvdd = true;205205+206206+ pdata->ldo1 = init_data;207207+ }208208+ } else if (dcvdd_node) {209209+ arizona->external_dcvdd = true;210210+ }211211+212212+ of_node_put(dcvdd_node);213213+214214+ return 0;215215+}216216+182217static int arizona_ldo1_probe(struct platform_device *pdev)183218{184219 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);···222185 struct regulator_config config = { };223186 struct arizona_ldo1 *ldo1;224187 int ret;188188+189189+ arizona->external_dcvdd = false;225190226191 ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);227192 if (!ldo1)···255216 config.dev = arizona->dev;256217 config.driver_data = ldo1;257218 config.regmap = arizona->regmap;219219+220220+ if (IS_ENABLED(CONFIG_OF)) {221221+ if (!dev_get_platdata(arizona->dev)) {222222+ ret = arizona_ldo1_of_get_pdata(arizona, &config);223223+ if (ret < 0)224224+ return ret;225225+ }226226+ }227227+258228 config.ena_gpio = arizona->pdata.ldoena;259229260230 if (arizona->pdata.ldo1)261231 config.init_data = arizona->pdata.ldo1;262232 else263233 config.init_data = &ldo1->init_data;234234+235235+ /*236236+ * LDO1 can only be used to supply DCVDD so if it has no237237+ * consumers then DCVDD is supplied externally.238238+ */239239+ if (config.init_data->num_consumer_supplies == 0)240240+ arizona->external_dcvdd = true;264241265242 ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config);266243 if (IS_ERR(ldo1->regulator)) {···285230 ret);286231 return ret;287232 }233233+234234+ of_node_put(config.of_node);288235289236 platform_set_drvdata(pdev, ldo1);290237
···468468 * order */469469};470470471471+bool cpufreq_next_valid(struct cpufreq_frequency_table **pos);472472+473473+/*474474+ * cpufreq_for_each_entry - iterate over a cpufreq_frequency_table475475+ * @pos: the cpufreq_frequency_table * to use as a loop cursor.476476+ * @table: the cpufreq_frequency_table * to iterate over.477477+ */478478+479479+#define cpufreq_for_each_entry(pos, table) \480480+ for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++)481481+482482+/*483483+ * cpufreq_for_each_valid_entry - iterate over a cpufreq_frequency_table484484+ * excluding CPUFREQ_ENTRY_INVALID frequencies.485485+ * @pos: the cpufreq_frequency_table * to use as a loop cursor.486486+ * @table: the cpufreq_frequency_table * to iterate over.487487+ */488488+489489+#define cpufreq_for_each_valid_entry(pos, table) \490490+ for (pos = table; cpufreq_next_valid(&pos); pos++)491491+471492int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,472493 struct cpufreq_frequency_table *table);473494
···11/*22- * max14577.h - Driver for the Maxim 1457722+ * max14577.h - Driver for the Maxim 14577/7783633 *44- * Copyright (C) 2013 Samsung Electrnoics44+ * Copyright (C) 2014 Samsung Electrnoics55 * Chanwoo Choi <cw00.choi@samsung.com>66 * Krzysztof Kozlowski <k.kozlowski@samsung.com>77 *···2020 * MAX14577 has MUIC, Charger devices.2121 * The devices share the same I2C bus and interrupt line2222 * included in this mfd driver.2323+ *2424+ * MAX77836 has additional PMIC and Fuel-Gauge on different I2C slave2525+ * addresses.2326 */24272528#ifndef __MAX14577_H__···3532 MAX14577_SAFEOUT = 0,3633 MAX14577_CHARGER,37343838- MAX14577_REG_MAX,3535+ MAX14577_REGULATOR_NUM,3636+};3737+3838+/* MAX77836 regulator IDs */3939+enum max77836_regulators {4040+ MAX77836_SAFEOUT = 0,4141+ MAX77836_CHARGER,4242+ MAX77836_LDO1,4343+ MAX77836_LDO2,4444+4545+ MAX77836_REGULATOR_NUM,3946};40474148struct max14577_regulator_platform_data {
+5-14
include/linux/mfd/stmpe.h
···1111#include <linux/mutex.h>12121313struct device;1414+struct regulator;14151516enum stmpe_block {1617 STMPE_BLOCK_GPIO = 1 << 0,···63626463/**6564 * struct stmpe - STMPE MFD structure6565+ * @vcc: optional VCC regulator6666+ * @vio: optional VIO regulator6667 * @lock: lock protecting I/O operations6768 * @irq_lock: IRQ bus lock6869 * @dev: device, mostly for dev_dbg()···7673 * @regs: list of addresses of registers which are at different addresses on7774 * different variants. Indexed by one of STMPE_IDX_*.7875 * @irq: irq number for stmpe7979- * @irq_base: starting IRQ number for internal IRQs8076 * @num_gpios: number of gpios, differs for variants8177 * @ier: cache of IER registers for bus_lock8278 * @oldier: cache of IER registers for bus_lock8379 * @pdata: platform data8480 */8581struct stmpe {8282+ struct regulator *vcc;8383+ struct regulator *vio;8684 struct mutex lock;8785 struct mutex irq_lock;8886 struct device *dev;···9591 const u8 *regs;96929793 int irq;9898- int irq_base;9994 int num_gpios;10095 u8 ier[2];10196 u8 oldier[2];···135132136133/**137134 * struct stmpe_gpio_platform_data - STMPE GPIO platform data138138- * @gpio_base: first gpio number assigned. A maximum of139139- * %STMPE_NR_GPIOS GPIOs will be allocated.140135 * @norequest_mask: bitmask specifying which GPIOs should _not_ be141136 * requestable due to different usage (e.g. touch, keypad)142137 * STMPE_GPIO_NOREQ_* macros can be used here.···142141 * @remove: board specific remove callback143142 */144143struct stmpe_gpio_platform_data {145145- int gpio_base;146144 unsigned norequest_mask;147145 void (*setup)(struct stmpe *stmpe, unsigned gpio_base);148146 void (*remove)(struct stmpe *stmpe, unsigned gpio_base);···195195 * @irq_trigger: IRQ trigger to use for the interrupt to the host196196 * @autosleep: bool to enable/disable stmpe autosleep197197 * @autosleep_timeout: inactivity timeout in milliseconds for autosleep198198- * @irq_base: base IRQ number. %STMPE_NR_IRQS irqs will be used, or199199- * %STMPE_NR_INTERNAL_IRQS if the GPIO driver is not used.200198 * @irq_over_gpio: true if gpio is used to get irq201199 * @irq_gpio: gpio number over which irq will be requested (significant only if202200 * irq_over_gpio is true)···205207struct stmpe_platform_data {206208 int id;207209 unsigned int blocks;208208- int irq_base;209210 unsigned int irq_trigger;210211 bool autosleep;211212 bool irq_over_gpio;···215218 struct stmpe_keypad_platform_data *keypad;216219 struct stmpe_ts_platform_data *ts;217220};218218-219219-#define STMPE_NR_INTERNAL_IRQS 9220220-#define STMPE_INT_GPIO(x) (STMPE_NR_INTERNAL_IRQS + (x))221221-222222-#define STMPE_NR_GPIOS 24223223-#define STMPE_NR_IRQS STMPE_INT_GPIO(STMPE_NR_GPIOS)224221225222#endif