Lines Matching +full:smbus +full:- +full:timeout +full:- +full:disable
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 SMBus driver for nVidia nForce2 MCP
7 Copyright (c) 2003 Hans-Frieder Vogt <hfvogt@arcor.de>,
9 SMBus 2.0 driver for AMD-8111 IO-Hub
21 nForce4 MCP-04 0034
35 /* Note: we assume there can only be one nForce2, with two SMBus interfaces */
50 MODULE_AUTHOR("Hans-Frieder Vogt <hfvogt@gmx.net>");
51 MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver");
64 * nVidia nForce2 SMBus control register definitions
72 * ACPI 2.0 chapter 13 SMBus 2.0 EC register model
74 #define NVIDIA_SMB_PRTCL (smbus->base + 0x00) /* protocol, PEC */
75 #define NVIDIA_SMB_STS (smbus->base + 0x01) /* status */
76 #define NVIDIA_SMB_ADDR (smbus->base + 0x02) /* address */
77 #define NVIDIA_SMB_CMD (smbus->base + 0x03) /* command */
78 #define NVIDIA_SMB_DATA (smbus->base + 0x04) /* 32 data registers */
79 #define NVIDIA_SMB_BCNT (smbus->base + 0x24) /* number of data
81 #define NVIDIA_SMB_STATUS_ABRT (smbus->base + 0x3c) /* register used to
84 #define NVIDIA_SMB_CTRL (smbus->base + 0x3e) /* control register */
106 /* We disable the second SMBus channel on these boards */
121 SMBus channel */
136 struct nforce2_smbus *smbus = adap->algo_data; in nforce2_abort() local
137 int timeout = 0; in nforce2_abort() local
140 dev_dbg(&adap->dev, "Aborting current transaction\n"); in nforce2_abort()
147 (timeout++ < MAX_TIMEOUT)); in nforce2_abort()
149 dev_err(&adap->dev, "Can't reset the smbus\n"); in nforce2_abort()
155 struct nforce2_smbus *smbus = adap->algo_data; in nforce2_check_status() local
156 int timeout = 0; in nforce2_check_status() local
162 } while ((!temp) && (timeout++ < MAX_TIMEOUT)); in nforce2_check_status()
164 if (timeout > MAX_TIMEOUT) { in nforce2_check_status()
165 dev_dbg(&adap->dev, "SMBus Timeout!\n"); in nforce2_check_status()
166 if (smbus->can_abort) in nforce2_check_status()
168 return -ETIMEDOUT; in nforce2_check_status()
171 dev_dbg(&adap->dev, "Transaction failed (0x%02x)!\n", temp); in nforce2_check_status()
172 return -EIO; in nforce2_check_status()
182 struct nforce2_smbus *smbus = adap->algo_data; in nforce2_access() local
206 outb_p(data->byte, NVIDIA_SMB_DATA); in nforce2_access()
213 outb_p(data->word, NVIDIA_SMB_DATA); in nforce2_access()
214 outb_p(data->word >> 8, NVIDIA_SMB_DATA + 1); in nforce2_access()
222 len = data->block[0]; in nforce2_access()
224 dev_err(&adap->dev, in nforce2_access()
227 return -EINVAL; in nforce2_access()
231 outb_p(data->block[i + 1], in nforce2_access()
238 dev_err(&adap->dev, "Unsupported transaction %d\n", size); in nforce2_access()
239 return -EOPNOTSUPP; in nforce2_access()
255 data->byte = inb_p(NVIDIA_SMB_DATA); in nforce2_access()
259 data->word = inb_p(NVIDIA_SMB_DATA) | in nforce2_access()
266 dev_err(&adap->dev, in nforce2_access()
269 return -EPROTO; in nforce2_access()
272 data->block[i + 1] = inb_p(NVIDIA_SMB_DATA + i); in nforce2_access()
273 data->block[0] = len; in nforce2_access()
287 (((struct nforce2_smbus *)adapter->algo_data)->blockops ? in nforce2_func()
319 struct nforce2_smbus *smbus, const char *name) in nforce2_probe_smb() argument
323 smbus->base = pci_resource_start(dev, bar); in nforce2_probe_smb()
324 if (smbus->base) { in nforce2_probe_smb()
325 smbus->size = pci_resource_len(dev, bar); in nforce2_probe_smb()
327 /* Older incarnations of the device used non-standard BARs */ in nforce2_probe_smb()
332 dev_err(&dev->dev, "Error reading PCI config for %s\n", in nforce2_probe_smb()
334 return -EIO; in nforce2_probe_smb()
337 smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; in nforce2_probe_smb()
338 smbus->size = 64; in nforce2_probe_smb()
341 error = acpi_check_region(smbus->base, smbus->size, in nforce2_probe_smb()
346 if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { in nforce2_probe_smb()
347 dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", in nforce2_probe_smb()
348 smbus->base, smbus->base+smbus->size-1, name); in nforce2_probe_smb()
349 return -EBUSY; in nforce2_probe_smb()
351 smbus->adapter.owner = THIS_MODULE; in nforce2_probe_smb()
352 smbus->adapter.class = I2C_CLASS_HWMON; in nforce2_probe_smb()
353 smbus->adapter.algo = &smbus_algorithm; in nforce2_probe_smb()
354 smbus->adapter.algo_data = smbus; in nforce2_probe_smb()
355 smbus->adapter.dev.parent = &dev->dev; in nforce2_probe_smb()
356 snprintf(smbus->adapter.name, sizeof(smbus->adapter.name), in nforce2_probe_smb()
357 "SMBus nForce2 adapter at %04x", smbus->base); in nforce2_probe_smb()
359 error = i2c_add_adapter(&smbus->adapter); in nforce2_probe_smb()
361 release_region(smbus->base, smbus->size); in nforce2_probe_smb()
364 dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n", in nforce2_probe_smb()
365 smbus->base); in nforce2_probe_smb()
375 /* we support 2 SMBus adapters */ in nforce2_probe()
378 return -ENOMEM; in nforce2_probe()
381 switch (dev->device) { in nforce2_probe()
391 /* SMBus adapter 1 */ in nforce2_probe()
396 /* SMBus adapter 2 */ in nforce2_probe()
398 dev_err(&dev->dev, "Disabling SMB2 for safety reasons.\n"); in nforce2_probe()
399 res2 = -EPERM; in nforce2_probe()
411 return -ENODEV; in nforce2_probe()