From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: Re: [RESEND PATCH v2 7/7] usb: typec: qcom: Add a pm8150b TCPM driver
Date: Sat, 30 Oct 2021 18:31:35 +0800 [thread overview]
Message-ID: <202110301822.cMPH2aH0-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 32195 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20211028164941.831918-8-bryan.odonoghue@linaro.org>
References: <20211028164941.831918-8-bryan.odonoghue@linaro.org>
TO: "Bryan O'Donoghue" <bryan.odonoghue@linaro.org>
TO: linux(a)roeck-us.net
TO: heikki.krogerus(a)linux.intel.com
TO: rdunlap(a)infradead.org
TO: gregkh(a)linuxfoundation.org
TO: bjorn.andersson(a)linaro.org
TO: robh+dt(a)kernel.org
TO: linux-usb(a)vger.kernel.org
TO: linux-arm-msm(a)vger.kernel.org
TO: devicetree(a)vger.kernel.org
CC: wcheng(a)codeaurora.org
Hi Bryan,
I love your patch! Perhaps something to improve:
[auto build test WARNING on usb/usb-testing]
[also build test WARNING on robh/for-next linus/master v5.15-rc7 next-20211029]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Bryan-O-Donoghue/Add-pm8150b-TPCM-driver/20211029-010406
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: riscv-randconfig-c006-20211028 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/fe4e9d995058581a4428c9c5c91e848eab3beef5
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Bryan-O-Donoghue/Add-pm8150b-TPCM-driver/20211029-010406
git checkout fe4e9d995058581a4428c9c5c91e848eab3beef5
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
#define WRITE_ONCE(x, val) \
^
drivers/dma-buf/heaps/system_heap.c:359:2: note: Returning from 'INIT_LIST_HEAD'
INIT_LIST_HEAD(&pages);
^~~~~~~~~~~~~~~~~~~~~~
drivers/dma-buf/heaps/system_heap.c:361:9: note: Assuming 'size_remaining' is <= 0
while (size_remaining > 0) {
^~~~~~~~~~~~~~~~~~
drivers/dma-buf/heaps/system_heap.c:361:2: note: Loop condition is false. Execution continues on line 381
while (size_remaining > 0) {
^
drivers/dma-buf/heaps/system_heap.c:382:6: note: Assuming the condition is true
if (sg_alloc_table(table, i, GFP_KERNEL))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/dma-buf/heaps/system_heap.c:382:2: note: Taking true branch
if (sg_alloc_table(table, i, GFP_KERNEL))
^
drivers/dma-buf/heaps/system_heap.c:383:3: note: Control jumps to line 413
goto free_buffer;
^
drivers/dma-buf/heaps/system_heap.c:413:2: note: Left side of '&&' is false
list_for_each_entry_safe(page, tmp_page, &pages, lru)
^
include/linux/list.h:715:13: note: expanded from macro 'list_for_each_entry_safe'
for (pos = list_first_entry(head, typeof(*pos), member), \
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/dma-buf/heaps/system_heap.c:413:2: note: Taking false branch
list_for_each_entry_safe(page, tmp_page, &pages, lru)
^
include/linux/list.h:715:13: note: expanded from macro 'list_for_each_entry_safe'
for (pos = list_first_entry(head, typeof(*pos), member), \
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:302:3: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^
drivers/dma-buf/heaps/system_heap.c:413:2: note: Loop condition is false. Exiting loop
list_for_each_entry_safe(page, tmp_page, &pages, lru)
^
include/linux/list.h:715:13: note: expanded from macro 'list_for_each_entry_safe'
for (pos = list_first_entry(head, typeof(*pos), member), \
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
do { \
^
drivers/dma-buf/heaps/system_heap.c:413:2: note: Assigned value is garbage or undefined
list_for_each_entry_safe(page, tmp_page, &pages, lru)
^
include/linux/list.h:716:7: note: expanded from macro 'list_for_each_entry_safe'
n = list_next_entry(pos, member); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:555:2: note: expanded from macro 'list_next_entry'
list_entry((pos)->member.next, typeof(*(pos)), member)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:494:2: note: expanded from macro 'container_of'
void *__mptr = (void *)(ptr); \
^ ~~~~~~~~~~~~~
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
12 warnings generated.
>> drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c:153:17: warning: Value stored to 'dev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct device *dev = pmic_typec->dev;
^~~ ~~~~~~~~~~~~~~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c:153:17: note: Value stored to 'dev' during its initialization is never read
struct device *dev = pmic_typec->dev;
^~~ ~~~~~~~~~~~~~~~
>> drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c:214:2: warning: Value stored to 'debounced' is never read [clang-analyzer-deadcode.DeadStores]
debounced = !!(misc & TYPEC_DEBOUNCE_DONE);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c:214:2: note: Value stored to 'debounced' is never read
debounced = !!(misc & TYPEC_DEBOUNCE_DONE);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c:308:2: warning: Value stored to 'orientation' is never read [clang-analyzer-deadcode.DeadStores]
orientation = !!(misc & CC_ORIENTATION);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c:308:2: note: Value stored to 'orientation' is never read
orientation = !!(misc & CC_ORIENTATION);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c:361:17: warning: Value stored to 'dev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct device *dev = pmic_typec->dev;
^~~ ~~~~~~~~~~~~~~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c:361:17: note: Value stored to 'dev' during its initialization is never read
struct device *dev = pmic_typec->dev;
^~~ ~~~~~~~~~~~~~~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c:399:17: warning: Value stored to 'dev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct device *dev = pmic_typec->dev;
^~~ ~~~~~~~~~~~~~~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c:399:17: note: Value stored to 'dev' during its initialization is never read
struct device *dev = pmic_typec->dev;
^~~ ~~~~~~~~~~~~~~~
Suppressed 7 warnings (5 in non-user code, 2 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
12 warnings generated.
>> drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:134:17: warning: Value stored to 'dev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct device *dev = pmic_pdphy->dev;
^~~ ~~~~~~~~~~~~~~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:134:17: note: Value stored to 'dev' during its initialization is never read
struct device *dev = pmic_pdphy->dev;
^~~ ~~~~~~~~~~~~~~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:243:3: warning: 4th function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
dev_err(dev, "pd_transmit_payload: %d hdr %*ph data %*ph ret %d\n",
^
include/linux/dev_printk.h:144:24: note: expanded from macro 'dev_err'
dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
^
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:258:6: note: Assuming 'msg' is non-null
if (msg) {
^~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:258:2: note: Taking true branch
if (msg) {
^
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:259:9: note: Calling 'qcom_pmic_tcpm_pdphy_pd_transmit_payload'
ret = qcom_pmic_tcpm_pdphy_pd_transmit_payload(pmic_pdphy, type,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:174:20: note: 'hdr_len' declared without an initial value
unsigned int val, hdr_len, txbuf_len, txsize_len;
^~~~~~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:178:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(&pmic_pdphy->lock, flags);
^
include/linux/spinlock.h:393:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:254:2: note: expanded from macro 'raw_spin_lock_irqsave'
do { \
^
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:178:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(&pmic_pdphy->lock, flags);
^
include/linux/spinlock.h:391:43: note: expanded from macro 'spin_lock_irqsave'
#define spin_lock_irqsave(lock, flags) \
^
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:183:6: note: Assuming 'ret' is not equal to 0
if (ret)
^~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:183:2: note: Taking true branch
if (ret)
^
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:184:3: note: Control jumps to line 240
goto done;
^
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:242:6: note: 'ret' is not equal to 0
if (ret) {
^~~
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:242:2: note: Taking true branch
if (ret) {
^
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:243:3: note: Left side of '&&' is true
dev_err(dev, "pd_transmit_payload: %d hdr %*ph data %*ph ret %d\n",
^
include/linux/dev_printk.h:144:2: note: expanded from macro 'dev_err'
dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
^
include/linux/dev_printk.h:109:3: note: expanded from macro 'dev_printk_index_wrap'
dev_printk_index_emit(level, fmt); \
^
include/linux/dev_printk.h:105:2: note: expanded from macro 'dev_printk_index_emit'
printk_index_subsys_emit("%s %s: ", level, fmt)
^
include/linux/printk.h:413:2: note: expanded from macro 'printk_index_subsys_emit'
__printk_index_emit(fmt, level, subsys_fmt_prefix)
^
include/linux/printk.h:370:7: note: expanded from macro '__printk_index_emit'
if (__builtin_constant_p(_fmt) && __builtin_constant_p(_level)) { \
^
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:243:3: note: Taking true branch
dev_err(dev, "pd_transmit_payload: %d hdr %*ph data %*ph ret %d\n",
^
include/linux/dev_printk.h:144:2: note: expanded from macro 'dev_err'
dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
^
include/linux/dev_printk.h:109:3: note: expanded from macro 'dev_printk_index_wrap'
dev_printk_index_emit(level, fmt); \
^
include/linux/dev_printk.h:105:2: note: expanded from macro 'dev_printk_index_emit'
printk_index_subsys_emit("%s %s: ", level, fmt)
^
include/linux/printk.h:413:2: note: expanded from macro 'printk_index_subsys_emit'
__printk_index_emit(fmt, level, subsys_fmt_prefix)
^
include/linux/printk.h:370:3: note: expanded from macro '__printk_index_emit'
if (__builtin_constant_p(_fmt) && __builtin_constant_p(_level)) { \
^
drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_pdphy.c:243:3: note: '?' condition is true
dev_err(dev, "pd_transmit_payload: %d hdr %*ph data %*ph ret %d\n",
^
include/linux/dev_printk.h:144:2: note: expanded from macro 'dev_err'
dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
^
include/linux/dev_printk.h:109:3: note: expanded from macro 'dev_printk_index_wrap'
dev_printk_index_emit(level, fmt); \
^
include/linux/dev_printk.h:105:2: note: expanded from macro 'dev_printk_index_emit'
printk_index_subsys_emit("%s %s: ", level, fmt)
vim +/dev +153 drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 150
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 151 int qcom_pmic_tcpm_typec_get_vbus(struct pmic_typec *pmic_typec)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 152 {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 @153 struct device *dev = pmic_typec->dev;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 154 unsigned int misc;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 155 int ret;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 156
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 157 ret = regmap_read(pmic_typec->regmap,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 158 pmic_typec->base + TYPEC_MISC_STATUS_REG,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 159 &misc);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 160 if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 161 misc = 0;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 162
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 163 dev_dbg(dev, "get_vbus: 0x%08x detect %d\n", misc, !!(misc & TYPEC_VBUS_DETECT));
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 164
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 165 return !!(misc & TYPEC_VBUS_DETECT);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 166 }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 167
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 168 int qcom_pmic_tcpm_typec_set_vbus(struct pmic_typec *pmic_typec, bool on)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 169 {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 170 u32 sm_stat;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 171 u32 val;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 172 int ret;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 173
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 174 if (on) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 175 ret = regulator_enable(pmic_typec->vdd_vbus);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 176 if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 177 return ret;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 178
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 179 val = TYPEC_SM_VBUS_VSAFE5V;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 180 } else {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 181 ret = regulator_disable(pmic_typec->vdd_vbus);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 182 if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 183 return ret;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 184
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 185 val = TYPEC_SM_VBUS_VSAFE0V;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 186 }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 187
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 188 /* Poll waiting for transition to required vSafe5V or vSafe0V */
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 189 ret = regmap_read_poll_timeout(pmic_typec->regmap,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 190 pmic_typec->base + TYPEC_SM_STATUS_REG,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 191 sm_stat, sm_stat & val,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 192 100, 250000);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 193 if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 194 dev_err(pmic_typec->dev, "vbus vsafe%dv fail\n", on ? 5 : 0);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 195
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 196 return ret;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 197 }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 198
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 199 int qcom_pmic_tcpm_typec_get_cc(struct pmic_typec *pmic_typec,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 200 enum typec_cc_status *cc1,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 201 enum typec_cc_status *cc2)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 202 {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 203 struct device *dev = pmic_typec->dev;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 204 unsigned int misc, val;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 205 bool attached, debounced;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 206 int ret = 0;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 207
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 208 ret = regmap_read(pmic_typec->regmap,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 209 pmic_typec->base + TYPEC_MISC_STATUS_REG, &misc);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 210 if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 211 goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 212
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 213 attached = !!(misc & CC_ATTACHED);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 @214 debounced = !!(misc & TYPEC_DEBOUNCE_DONE);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 215
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 216 if (pmic_typec->debouncing_cc) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 217 ret = -EBUSY;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 218 goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 219 }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 220
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 221 *cc1 = TYPEC_CC_OPEN;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 222 *cc2 = TYPEC_CC_OPEN;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 223
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 224 if (!(attached))
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 225 goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 226
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 227 if (misc & SNK_SRC_MODE) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 228 ret = regmap_read(pmic_typec->regmap,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 229 pmic_typec->base + TYPEC_SRC_STATUS_REG,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 230 &val);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 231 if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 232 goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 233 switch (val & DETECTED_SRC_TYPE_MASK) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 234 case SRC_RD_OPEN:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 235 val = TYPEC_CC_RD;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 236 break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 237 case SRC_RD_RA_VCONN:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 238 val = TYPEC_CC_RD;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 239 *cc1 = TYPEC_CC_RA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 240 *cc2 = TYPEC_CC_RA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 241 break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 242 default:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 243 dev_warn(dev, "unexpected src status %.2x\n", val);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 244 val = TYPEC_CC_RD;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 245 break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 246 }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 247 } else {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 248 ret = regmap_read(pmic_typec->regmap,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 249 pmic_typec->base + TYPEC_SNK_STATUS_REG,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 250 &val);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 251 if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 252 goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 253 switch (val & DETECTED_SNK_TYPE_MASK) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 254 case SNK_RP_STD:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 255 val = TYPEC_CC_RP_DEF;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 256 break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 257 case SNK_RP_1P5:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 258 val = TYPEC_CC_RP_1_5;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 259 break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 260 case SNK_RP_3P0:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 261 val = TYPEC_CC_RP_3_0;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 262 break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 263 default:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 264 dev_warn(dev, "unexpected snk status %.2x\n", val);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 265 val = TYPEC_CC_RP_DEF;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 266 break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 267 }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 268 val = TYPEC_CC_RP_DEF;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 269 }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 270
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 271 if (misc & CC_ORIENTATION)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 272 *cc2 = val;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 273 else
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 274 *cc1 = val;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 275
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 276 done:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 277 dev_dbg(dev, "get_cc: misc 0x%08x cc1 0x%08x %s cc2 0x%08x %s attached %d cc=%s\n",
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 278 misc, *cc1, cc_to_name(*cc1), *cc2, cc_to_name(*cc2), !!(misc & CC_ATTACHED),
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 279 misc_to_cc(misc));
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 280
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 281 return ret;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 282 }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 283
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 284 static void qcom_pmic_set_cc_debounce(struct pmic_typec *pmic_typec)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 285 {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 286 pmic_typec->debouncing_cc = true;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 287 schedule_delayed_work(&pmic_typec->cc_debounce_dwork,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 288 msecs_to_jiffies(2));
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 289 }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 290
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 291 int qcom_pmic_tcpm_typec_set_cc(struct pmic_typec *pmic_typec,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 292 enum typec_cc_status cc)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 293 {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 294 struct device *dev = pmic_typec->dev;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 295 unsigned int mode, currsrc;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 296 unsigned int orientation, misc;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 297 unsigned long flags;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 298 int ret;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 299
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 300 spin_lock_irqsave(&pmic_typec->lock, flags);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 301
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 302 ret = regmap_read(pmic_typec->regmap,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 303 pmic_typec->base + TYPEC_MISC_STATUS_REG,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 304 &misc);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 305 if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 306 goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 307
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 @308 orientation = !!(misc & CC_ORIENTATION);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 309
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 310 mode = EN_SRC_ONLY;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 311
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 312 switch (cc) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 313 case TYPEC_CC_OPEN:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 314 currsrc = TYPEC_SRC_RP_SEL_80UA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 315 break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 316 case TYPEC_CC_RP_DEF:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 317 currsrc = TYPEC_SRC_RP_SEL_80UA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 318 break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 319 case TYPEC_CC_RP_1_5:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 320 currsrc = TYPEC_SRC_RP_SEL_180UA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 321 break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 322 case TYPEC_CC_RP_3_0:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 323 currsrc = TYPEC_SRC_RP_SEL_330UA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 324 break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 325 case TYPEC_CC_RD:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 326 currsrc = TYPEC_SRC_RP_SEL_80UA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 327 mode = EN_SNK_ONLY;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 328 break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 329 default:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 330 dev_warn(dev, "unexpected set_cc %d\n", cc);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 331 ret = -EINVAL;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 332 goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 333 }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 334
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 335 if (mode == EN_SRC_ONLY) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 336 ret = regmap_write(pmic_typec->regmap,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 337 pmic_typec->base + TYPEC_CURRSRC_CFG_REG,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 338 currsrc);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 339 if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 340 goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 341 }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 342
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 343 pmic_typec->cc = cc;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 344 qcom_pmic_set_cc_debounce(pmic_typec);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 345 ret = 0;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 346
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 347 done:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 348 spin_unlock_irqrestore(&pmic_typec->lock, flags);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 349
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 350 dev_dbg(dev, "set_cc: currsrc=%x %s mode %s debounce %d attached %d cc=%s\n",
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 351 currsrc, rp_sel_to_name(currsrc),
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 352 mode == EN_SRC_ONLY ? "EN_SRC_ONLY" : "EN_SNK_ONLY",
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 353 pmic_typec->debouncing_cc, !!(misc & CC_ATTACHED),
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 354 misc_to_cc(misc));
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 355
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 356 return ret;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 357 }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 358
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 36135 bytes --]
next reply other threads:[~2021-10-30 10:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-30 10:31 kernel test robot [this message]
2021-11-05 5:45 ` [RESEND PATCH v2 7/7] usb: typec: qcom: Add a pm8150b TCPM driver kernel test robot
2021-11-05 5:45 ` kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2021-10-28 16:49 [RESEND PATCH v2 0/7] Add pm8150b TPCM driver Bryan O'Donoghue
2021-10-28 16:49 ` [RESEND PATCH v2 7/7] usb: typec: qcom: Add a pm8150b TCPM driver Bryan O'Donoghue
2021-10-29 16:40 ` kernel test robot
2021-10-29 16:40 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202110301822.cMPH2aH0-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.