This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AMC6821: Linux Device Driver

Part Number: AMC6821

Hii,

I am trying to use the AMC6821 Linux Device Driver, for Controlling FAN Speed, As per the Kernel Documentation I have Followed the steps on how to insmod this module and here are the steps I have did.

1. Added Device Tree Binding For AMC6821 which is as follows.

i2c-mux@74 {
                compatible = "nxp,pca9548";
                #address-cells = <0x1>;
                #size-cells = <0x0>;
                reg = <0x74>;

               i2c@5 {
                                        #address-cells = <0x1>;
                                        #size-cells = <0x0>;
                                        reg = <0x5>;
                                    
                                       amc6821@18 {
                                         compatible = "ti,amc6821";
                                         reg = <0x18>;
                                     };
                                 };

2. When I am trying to Load the Module (amc6821.ko file) I am getting the following errors

  root@zcu102-zynqmp:~# insmod amc6821.ko init=1  pwminv=1;
[    5.635243] amc6821 12-0018: Configuration register write error, aborting.
[    5.642122] amc6821: probe of 12-0018 failed with error -5
 

Which means the AMC6821 Chip was Not Initialising  Properly, And  may I know the Reason for the same ??

Regards,

Shubhakara P S

  • Hi Shubhakara,

    Let me reach out to our Linux team for information on this. 

    Thanks,

  • Hi Shubhakara,

    Can you send a oscilloscope waveform of the I2C transaction?  Also can you send me schematic of the device.

    Thanks,

  • Hii,

    Well this is due to the problem of frequency setting for SCLK , AMC6821 Supports Max clock Frequency of 100 KHZ, and we have changed the Master Clock Frequency from 400KHZ to 100KHZ, well as off now we are getting the clock and the device is probed successfully.

    And we are checking the PWM_OUT Signal in Oscilloscope at J5 (11), we are not getting any waveform at this pin.

    I think so the driver initialises the chip by default in Software DCY Mode we did not change anything in the driver configuration just we have loaded the Driver using insmod amc6821.ko with init=1

    And we got the following sysfs attributes in /sys/class/hwmon/hwmon20

    device                   pwm1_auto_channels_temp  temp1_crit_alarm         temp2_crit_alarm
    fan1_div                 pwm1_auto_point1_pwm     temp1_input              temp2_fault
    fan1_fault               pwm1_auto_point2_pwm     temp1_max                temp2_input
    fan1_input               pwm1_auto_point3_pwm     temp1_max_alarm          temp2_max
    fan1_max                 pwm1_enable              temp1_min                temp2_max_alarm
    fan1_min                 subsystem                temp1_min_alarm          temp2_min
    name                     temp1_auto_point1_temp   temp2_auto_point1_temp   temp2_min_alarm
    of_node                  temp1_auto_point2_temp   temp2_auto_point2_temp   uevent
    power                    temp1_auto_point3_temp   temp2_auto_point3_temp
    pwm1                     temp1_crit               temp2_crit

    When I do cat pwm1_enable , it shows 1 which means in the driver code case 1 is executed

    long val;
            int config = kstrtol(buf, 10, &val);
            if (config)
                    return config;

            mutex_lock(&data->update_lock);
            config = i2c_smbus_read_byte_data(client, AMC6821_REG_CONF1);
            if (config < 0) {
                            dev_err(&client->dev,
                            "Error reading configuration register, aborting.\n");
                            count = config;
                            goto unlock;
            }

            switch (val) {
            case 1:
                    config &= ~AMC6821_CONF1_FDRC0;
                    config &= ~AMC6821_CONF1_FDRC1;
                    break;

    So, If Both the FDRC0 and FDRC1 Bit is 0
    0 0     ---> Software DCY control. Host writes DCY register to set the PWM duty cycle directly.

    So, we have setted the pw1_enable to 1 and we are trying change the pwm1 file , by writing the values from 0 to 255, But we are Not getting any waveforms on PWM_OUT(J5-11) Pin.









    Regards,

    Shubhakara P S

  • Hi Shubhakara,

    Can you please send me your schematic and a register dump of your settings?

    Thanks,

  • Hii,

    Here is the Register Dump  printed in init_client function at Boot Up

    [14418.411172] config @ addr: 0x04 AMC6821_REG_CONF4: 0x88
    [14418.416340] after "config |= AMC6821_CONF4_MODE"
    [14418.420929] config @ addr: 0x04 AMC6821_REG_CONF4: 0x88
    [14418.426878] config @ addr: 0x3F AMC6821_REG_CONF3: 0x03
    [14418.432030] amc6821 12-0018: Revision 3
    [14418.435840] after "config &= ~AMC6821_CONF3_THERM_FAN_EN"
    [14418.441223] config @ addr: 0x3F AMC6821_REG_CONF3: 0x03
    [14418.447305] config @ addr: 0x01 AMC6821_REG_CONF2: 0x01
    [14418.452451] after "config &= ~AMC6821_CONF2_RTFIE"
    [14418.457219] after "config &= ~AMC6821_CONF2_LTOIE"
    [14418.461994] after "config &= ~AMC6821_CONF2_RTOIE"
    [14418.466768] config @ addr: 0x01 AMC6821_REG_CONF2: 0x01
    [14418.472856] config @ addr: 0x00 AMC6821_REG_CONF1: 0x09
    [14418.478002] after "config &= ~AMC6821_CONF1_THERMOVIE"
    [14418.483123] after "config &= ~AMC6821_CONF1_FANIE"
    [14418.487897] after "config |= AMC6821_CONF1_START"
    [14418.492586] config @ addr: 0x00 AMC6821_REG_CONF1: 0x09
    [14418.497793] value of PWMINV After Making 1 is 9
    [14418.503052] pwminv: 0x1
    [14418.505415] config @ addr: 0x00 AMC6821_REG_CONF1: 0x09

  • Hi Shubhakara, 

    I am able to see the PWM signal with those settings on my set up.  Can you please send me your schematic.  Also, to what value is register 0x22 set?

    Thanks,

  • Shubhakara,

    Thanks for the information from these threads e2e.ti.com/.../871574 and https://e2e.ti.com/support/sensors/f/1023/t/871579 . 

    Please check jumpers W7 and J5 pin 9-10 connection for PWMOUT Pull-up.

    Do you see the PWMOUT waveform without the fan connected to the EVM?

    Thanks,

  • Hi David,

    W7 jumper is  connect for position 1 - 2.
    In J5 jumper 9 - 10 are connected

    We are testing this TI's AMC6821 EVM with Xilinx ZCU102 board (having zynq ultrascale+ on it) which works at 3.3v. Therefore AMC6821 EVM is jumpered to work at 3.3v
    We are able to see 3.3v VDD on Pin-6. But on PWM-OUT Pin-1 we always observe fixed 1v all the time on the CRO. Never seen any waveform, irespective of what values we try writing to DCY register and other configuration registers.

  • Hi Shubhakara,

    For clarification, when you say "observe fixed 1v" do you mean fixed high (3.3V) or is it the pin pulling the pull-up voltage down to 1V?

    Can you check the status registers 0x02 and 0x03 to make sure there are no faults that might cause PWMOUT to stay high?

    Also, can you try to toggle the PWMOUT by using 0x00 bit 3.

    Thanks,

  • HI David,


    For clarification, when you say "observe fixed 1v" do you mean fixed high (3.3V) or is it the pin pulling the pull-up voltage down to 1V?

    Yes, it is Fixed 1v, Don't know whether it is the PIn pulling the Pull-up voltage down to 1V, just we have observed the waveform at PWM_OUT Pin , it is always constant 1V.

    Okay, let me read out these Registers , and get Back to you.



    Regards,

    Shubhakara P S

  • Hi David,

    Can you check the status registers 0x02 and 0x03 to make sure there are no faults that might cause PWMOUT to stay high?

    Status Registers 0x02 and 0x03 are set to Default (0x00, 0x00) , We are not modifying anything in these registers, as you can see in the driver code snippet below
     
    drivers/hwmon/amc6821.c

    #define AMC6821_REG_STAT1 0x02
    #define AMC6821_REG_STAT2 0x03

    data->stat1 = i2c_smbus_read_byte_data(client,
                            AMC6821_REG_STAT1);
                    data->stat2 = i2c_smbus_read_byte_data(client,
                            AMC6821_REG_STAT2);

    Also, can you try to toggle the PWMOUT by using 0x00 bit 3.  ?

    Yes, we are toggling out this pin (PWMINV) , By default it will be 0 , and we are inverting it, while loading the kernel module as follows.

    insmod amc6821.ko init=1 pwminv=1

    when pwminv=1 and in the driver snippet code

    if (pwminv)
                            config |= AMC6821_CONF1_PWMINV;
                    else
                            config &= ~AMC6821_CONF1_PWMINV;


    Regards,

    Shubhakara P S

  • Hi David,

    Good Morning, I am waiting For Your Response !





    Regards,

    Shubhakara P S

  • Hi David,

    For clarification, when you say "observe fixed 1v" do you mean fixed high (3.3V) or is it the pin pulling the pull-up voltage down to 1V?

    When i say "observe fixed 1v", i am talking about reading voltage value of 1 volt on oscilloscope (not the logic level of 1). So yes, it will be correct to say that the pin is puling the pull-up voltage down to 1V. On J5, 9 - 10 shorted (connected) and 11 - 12 are left open.
    When i measure the terminal of R13 that is connected to VDD, it measures 3.3V but on the terminal of R13 connected to pin 10 of J5 measures 1V.





    Thanks & Regards,

    Shubhakara P S

  • Hi Shubahakara,

    Please check the pull-up voltage and the jumpers on your board.  This pin is open drain so I do not expect the voltage to be much less than the pull-up voltage. I am sending you a picture of my EVM configuration for reference. 

    Thanks,

  • Hi David,

    Thank you so much for your Valuable Support , The issue had been Solved, The chip had gone Bad, We replaced one more chip then it works fine.











    Thanks & Regards,

    Shubhakara P S

  • Shubhakara,

    I am glad your set up is now working.  Thanks for posting to the e2e!

    Thanks,