adt7475.c (2ecff39791bd3b33c8dcf0d241fa740dba7b79e6) adt7475.c (86da28eed4fbc64dfdc386337f6cbac36c9c1ed2)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives
4 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc.
5 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
6 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com>
7 * Copyright (C) 2009 Jean Delvare <jdelvare@suse.de>
8 *

--- 1495 unchanged lines hidden (view full) ---

1504 data->config2);
1505 if (ret < 0)
1506 return ret;
1507 }
1508
1509 return 0;
1510}
1511
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives
4 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc.
5 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
6 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com>
7 * Copyright (C) 2009 Jean Delvare <jdelvare@suse.de>
8 *

--- 1495 unchanged lines hidden (view full) ---

1504 data->config2);
1505 if (ret < 0)
1506 return ret;
1507 }
1508
1509 return 0;
1510}
1511
1512static int adt7475_set_pwm_polarity(struct i2c_client *client)
1513{
1514 u32 states[ADT7475_PWM_COUNT];
1515 int ret, i;
1516 u8 val;
1517
1518 ret = of_property_read_u32_array(client->dev.of_node,
1519 "adi,pwm-active-state", states,
1520 ARRAY_SIZE(states));
1521 if (ret)
1522 return ret;
1523
1524 for (i = 0; i < ADT7475_PWM_COUNT; i++) {
1525 ret = adt7475_read(PWM_CONFIG_REG(i));
1526 if (ret < 0)
1527 return ret;
1528 val = ret;
1529 if (states[i])
1530 val &= ~BIT(4);
1531 else
1532 val |= BIT(4);
1533
1534 ret = i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(i), val);
1535 if (ret)
1536 return ret;
1537 }
1538
1539 return 0;
1540}
1541
1512static int adt7475_probe(struct i2c_client *client,
1513 const struct i2c_device_id *id)
1514{
1515 enum chips chip;
1516 static const char * const names[] = {
1517 [adt7473] = "ADT7473",
1518 [adt7475] = "ADT7475",
1519 [adt7476] = "ADT7476",

--- 92 unchanged lines hidden (view full) ---

1612
1613 /*
1614 * Call adt7475_read_pwm for all pwm's as this will reprogram any
1615 * pwm's which are disabled to manual mode with 0% duty cycle
1616 */
1617 for (i = 0; i < ADT7475_PWM_COUNT; i++)
1618 adt7475_read_pwm(client, i);
1619
1542static int adt7475_probe(struct i2c_client *client,
1543 const struct i2c_device_id *id)
1544{
1545 enum chips chip;
1546 static const char * const names[] = {
1547 [adt7473] = "ADT7473",
1548 [adt7475] = "ADT7475",
1549 [adt7476] = "ADT7476",

--- 92 unchanged lines hidden (view full) ---

1642
1643 /*
1644 * Call adt7475_read_pwm for all pwm's as this will reprogram any
1645 * pwm's which are disabled to manual mode with 0% duty cycle
1646 */
1647 for (i = 0; i < ADT7475_PWM_COUNT; i++)
1648 adt7475_read_pwm(client, i);
1649
1650 ret = adt7475_set_pwm_polarity(client);
1651 if (ret && ret != -EINVAL)
1652 dev_warn(&client->dev, "Error configuring pwm polarity\n");
1653
1620 /* Start monitoring */
1621 switch (chip) {
1622 case adt7475:
1623 case adt7476:
1624 i2c_smbus_write_byte_data(client, REG_CONFIG1,
1625 adt7475_read(REG_CONFIG1) | 0x01);
1626 break;
1627 default:

--- 268 unchanged lines hidden ---
1654 /* Start monitoring */
1655 switch (chip) {
1656 case adt7475:
1657 case adt7476:
1658 i2c_smbus_write_byte_data(client, REG_CONFIG1,
1659 adt7475_read(REG_CONFIG1) | 0x01);
1660 break;
1661 default:

--- 268 unchanged lines hidden ---