pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS


[PATCH] eag-mx25/board: pcf2127 fixup OSF
Posted by Anonymous on Tue 26th Mar 2019 11:33
raw | new post

  1. From: Gavin Schenk <g.schenk@eckelmann.de>
  2. Date: Tue, 26 Mar 2019 12:31:50 +0100
  3. Subject: [PATCH] eag-mx25/board: pcf2127 fixup OSF
  4.  
  5. ---
  6. arch/arm/boards/eag-mx25/board.c | 46 ++++++++++++++++++++++++++++++++++++++++
  7.  1 file changed, 46 insertions(+)
  8.  
  9. diff --git a/arch/arm/boards/eag-mx25/board.c b/arch/arm/boards/eag-mx25/board.c
  10. index f581454c1a8f..b2ef66a80649 100644
  11. --- a/arch/arm/boards/eag-mx25/board.c
  12. +++ b/arch/arm/boards/eag-mx25/board.c
  13. @@ -11,6 +11,7 @@
  14.  #include <mach/imxfb.h>
  15.  #include <mach/devices-imx25.h>
  16.  #include <gpio.h>
  17. +#include <i2c/i2c.h>
  18.  
  19.  static int imx25_eag_pmic_init(void)
  20.  {
  21. @@ -27,6 +28,51 @@ static int imx25_eag_pmic_init(void)
  22.  }
  23.  late_initcall(imx25_eag_pmic_init);
  24.  
  25. +static int imx25_eag_handle_pcf2127_osf(void)
  26. +{
  27. +       int ret=0;
  28. +       struct i2c_adapter *adapter = NULL;
  29. +       struct i2c_client client;
  30. +       u8 buf[0x1f];
  31. +       u8 value;
  32. +
  33. +       adapter = i2c_get_adapter(0);
  34. +       if (!adapter) {
  35. +               return -ENODEV;
  36. +       }
  37. +
  38. +       client.adapter = adapter;
  39. +       client.addr = 0x51;
  40. +
  41. +       ret = i2c_read_reg(&client, 0x1b, &buf[0], 0x1f);
  42. +       if (ret != 0x1f)
  43. +               return 1;
  44. +
  45. +       // If OSF is not set we are done
  46. +       if( !(buf[0x3] & 0x80) )
  47. +               return 0;
  48. +
  49. +       printf("pcf2127 OSF bit is set\n");
  50. +
  51. +       // Year 1980, RTC must be set by user
  52. +       if( buf[0xa] == 0x80 ){
  53. +               printf("RTC must be set by user in linux\n");
  54. +               return 2;
  55. +       }
  56. +
  57. +       // We hope the time is accurate and reset OSF bit
  58. +       value = buf[0x3];
  59. +       value &=~0x80;
  60. +       ret = i2c_write_reg(&client,0x3,&value,1);
  61. +       if ( ret != 1 ){
  62. +               return 3;
  63. +       }
  64. +
  65. +       printf("pcf2127 OSF bit fixed successfully\n");
  66. +       return 0;
  67. +}
  68. +late_initcall(imx25_eag_handle_pcf2127_osf);
  69. +
  70.  static const iomux_v3_cfg_t imx25_eag_ci4000_lcdc_pins[] = {
  71.         MX25_PAD_LD0__LD0,
  72.         MX25_PAD_LD1__LD1,

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at