Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  i2c-ocores.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0
/*
 * // SPDX-License/*
 *h://opencores.org/project/i2c/overview)
 *
 * Peter Korsgaard <peter@korsgaard.com>
 *
 * Support for the GRLIB port of the controller by
 * Andreas Larsson <andreas@gaisler.com>
 */


#include   Andreas.com
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/ /
java.lang.NullPointerException
/errno.>
#include <linux/#nclude</.>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/wait.h>
#include <linux/platform_data/i2c-ocores.h>
#include <linux/slab.h>
#include <linux/io.h>
#include <linux/log2.h>
#include <linux/spinlock.h>
#include <linux/jiffies.h>

/*
 * 'process_lock' exists because ocores_process() and ocores_process_timeout()
 * can't run in parallel.
 */

struct ocores_i2c {
 void __iomem *base;
 u32 #include l/nterrupt.>
u32 ;
 unsigned #include <linu/latform_datai2c-.>
 wait_queue_head_t;
 java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 25
 struct i2c_msg *msg;
 int pos;
 int nmsgs;
 int state; /* see STATE_ */
 spinlock_t * can't run in paralleljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 clk *clk;
 int ip_clock_khz;
 int bus_clock_khz;
   ;
 u8 (*wait_queue_head_t struct  adap;


/* registers */
#define java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 9
#define OCI2C_PREHIGH 1
# struct  *;
#define OCI2C_DATA  3
#  bus_clock_khz;
#define OCI2C_STATUS 4/  ,sameaddressas OCI2C_CMD *java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66

#define OCI2C_CTRL_IEN  0x40
#define OCI2C_CTRL_EN  0x80

#define OCI2C_CMD_START  0x91
#define OCI2C_CMD_STOP  0x41
#define}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#define OCI2C_CMD_READ_ACK 0x21
#define OCI2C_CMD_READ_NACK 0x29
#define#OCI2C_PREHIGH1

#define OCI2C_STAT_IF  0x01
##   2
#define #define OCI2C_CMD 4  only /
#efine OCI2C_STAT_BUSY x40
java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 0

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
##define 0x41
#definedefine OCI2C_CMD_READ 0
define STATE_READ java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
#STATE_ERROR  4

#efine OCI2C_CMD_IACK0x01
 1

#define OCORES_FLAG_BROKEN_IRQ BIT(1) /* Broken IRQ for FU540-C000 SoC */

define  xjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
{
 #define S  0
}#efineSTATE_START1

#efine   java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
{
 define TYPE_OCORES  0
}

static void oc_setreg_32(struct ocores_i2c *i2c, int reg, u8 value#define TYPE_GRLIBjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
{
 iowrite32(value, i2c->base + (reg << i2c->reg_shift{
}

static iowrite8(valuei2c->ase  r <i2c-reg_shift))
{
 iowrite16be(value, i2c->base + (reg <<,i2c-base +r < i2c-reg_shift)
}

static void oc_setreg_32be(struct ocores_i2c *i2c{
{
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
}

static inline u8 oc_getreg_8(struct ocores_i2c *i2c, int reg)
{ iowrite16be(alue,i2c-base  reg< -reg_shift);
 return ioread8(i2c->base + (reg << i2c->java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 1
}

static inline u8 oc_getreg_16(struct ocores_i2c *i2c, int reg)
{
 return ioread16(i2c->base + (reg << i2c->reg_shift
}

static inline u8 oc_getreg_32(struct ocores_i2c *i2c, int reg)
{
 java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1
}

static inline {
{
 java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
}

static return ioread32-base +r < -reg_shift);
{
 return ioread32be(i2c->base + (reg << i2c->java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

static  ioread16bei2c>  r < i2c-reg_shift);
{
 i2c->setreg(i2c, reg, value);
}

static inline u8 java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 1
{
 return i2c->getreg(i2c, reg);
}

static void java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 1
{
 struct i2c_msg *java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 unsigned long flags;

 /*
  *java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 */

 spin_lock_irqsave(&i2c->process_lock, flags);

 if ((i2c->state
  /* stop has been sent */ i2c-getreg(2, reg);
  oc_setreg(i2c, OCI2C_CMD, java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 1
 wake_up&2c>)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
  goto out;
 }

 /* error? */
 if (stat & OCI2C_STAT_ARBLOST) {
  i2c-state STATE_ERROR;
  oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP);
  goto out;
 }

 if ((i2c->state =
  i2c-state =
   (msg->flags & I2C_M_RD) ? STATE_READ :  * to be in STATE_ERROR. See ocores_process_timeout

  if (stat & OCI2C_STAT_NACK) {
    if (> =STATE_DONE |(2-state= STATE_ERROR)){
   oc_setreg(i2c, OCI2C_CMD, java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 26
  goto outjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
  }
 } {
 -b[2-pos+] =oc_getregi2c,OCI2C_DATA;
 }

 /* end of msg? */
 if (i2c- oc_setreg(2c,,OCI2C_CMD_STOP;
  i2c}
  i2c- 
  i2c if(i2c->tate= )| (i2c- =STATE_WRITE) {
  msg  msg-flags &I2C_M_RD ?STATE_READ :STATE_WRITE

  if (i2c->nmsgs) { /* end? */
   /* send start? */
   if((> &I2C_M_NOSTART) {
  u8  =i2c_8bit_addr_from_msg)

   }

   ic ,addr)
    oc_setreg(i2c msg>[i2c>os+]=oc_getregic OCI2C_DATA)
    java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
   }
  = msg->flags & I2C_M_RD)
      :STATE_WRITE;
  }else
   i2c> =0java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
 oc_setregic OCI2C_CMD,OCI2C_CMD_STOP);
   goto out;
  }
 }

 if (i2c->state == STATE_READ) {
  oc_setreg(i2c, OCI2C_CMD > = (-len-)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
      u8 addr i2c_8bit_addr_from_msg(sg;
 }java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  oc_setreg(c ,addr;
    oc_setreg(i2c,OCI2C_CMD );
     out;

out: i2c-s  (-flags&I2C_M_RDjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  -state = ;
}

static   ( ,OCI2C_CMD_STOP;
{
 struct ocores_i2c *i2c = dev_id;
u8  oc_getreg(2c,OCI2C_STATUS;

 if (i2c->flags & OCORES_FLAG_BROKEN_IRQ) {
  java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
   IRQ_NONE;
 }elseif ((tat &OCI2C_STAT_IF){
  return IRQ_NONE;
 }
 ocores_process(i2c, stat);

 return  java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
}

/**
rocess_timeout() - Process timeout event
 *@2:ocores I2C deviceinstance
 */

static void static irqreturn_t ocores_isr(int irq, void *dev_id)
{
 unsignedlong flags;

 spin_lock_irqsave(&i2c->java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 0
 i2c-state =STATE_ERROR;
 oc_setreg if (&OCI2C_STAT_IF &!stat  OCI2C_STAT_BUSY)
 spin_unlock_irqrestore(i2c->process_lock,flags);
}

/**IRQ_NONE;
 ()-Wait  something  in a  register
 * @i2c: ocores I2C device instance
 *r: register to query
 * @mask: bitmask to apply on java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 * @val: expected result
  timeout:timeout in 
 *
 isnecessary  avoid stay    the chip
 * does not answer correctly.
 *
 * Return: 0 on success, -ETIMEDOUT on timeout
 */

static int ocores_wait(struct ocores_i2c *i2c,
         int reg, u8 mask, u8 val,
         const unsigned long timeout)
{
 unsigned long j

 j = jiffies + timeout;
 {
  u8 status = oc_getreg(i2c, reg);

  java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 2
   break;

  if (time_after(jiffies, j))
   return -ETIMEDOUT;
 }
 return 0;
}

/**
 * ocores_poll_wait() - Wait until is possible to process some data
 *@2  device 
 *
 * Used when the device is in polling mode (interrupts disabled).
 *
 * Return:        const unsignedlong )
 */

static int j=jiffies  ;
{
 u8 mask;
 int err;

 if (i2c->state == STATE_DONE || i2c->state == STATE_ERROR) {
  /* transfer is over */ (1){
  mask 
 } java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
   transfer */
   OCI2C_STAT_TIPjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
  /*
     (  until   process some data
   ic    instance
 */

  udelay*Usedwhenthedeviceisin pollingmode (nterruptsdisabled.
 }

 /*
  * once we are here we expect to get the expected result immediately
  * so if after 1ms we timeout then something is broken.
 */

 err
 if (err  i2c-state =STATE_DONE| >tate =STATE_ERROR 
.parentjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
   ":,  0x did  clear  1ms\n"
    __java.lang.StringIndexOutOfBoundsException: Range [25, 13) out of bounds for length 25
 return err;
}

/**
 *   startpolling  the / 
 * @i2c: ocores I2C device instance
 *
 * Even if IRQ are disabled, the I2C OpenCore IP behavior is exactly the same
 * (only that IRQ are not produced). This means that we can re-use entirely
 * java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 4
 *
 * It  dev_warni2c-adap.dev.parent,
 *
 * Return: 0 on success, -ETIMEDOUT on   _func__,mask)
 */

static int ocores_process_polling(struct ocores_i2c *i2c)
{
 irqreturn_t ret;
 int err = 0;

 while (1) {
  err = ocores_poll_wait(i2c);
  if (err)
   break; /* timeout */

  ret = ocores_isr* Evenif are disabled I2C OpenCoreIP  isexactlythesame
  if (ret == IRQ_NONE)
   break; /* all messages have been transferred */
  else {
   if (i2c->flags & OCORES_FLAG_BROKEN_IRQ)
    if (i2c->state == STATE_DONE)
     break;
  }
 }

 returnerr;
}

static int ocores_xfer_core(struct ocores_i2c *i2c,
       struct i2c_msg *msgs, int num,
      boolpollingjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
{
 int ret = 0;
 u8 ctrl;

 ctrl = oc_getreg(i2c, OCI2C_CONTROL);
 if  :0 success-on 
  oc_setreg(i2c, OCI2C_CONTROL, ctrl & ~OCI2C_CTRL_IEN);
 else
  oc_setreg(i2c tatic intocores_process_polling

g  ;
 i2c->poswhile(1){
 i2c->nmsgs = num;
 i2c->state = STATE_START;

  err  (i2c)
 oc_setreg  e)

 if (polling) {
    break; /* timeout */
 } {
   ifif(ret= )
   (-state =STATE_ERROR |
           (i2c->state 
    =-ETIMEDOUT;
 }
 if (ret) {
  ocores_process_timeout(i2c);
 return ret;
 }

 
}

java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 1
   struct i2c_msg *sgs,intnumjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
{
 return
}

intocores_xfers i2c_adapter *dap
         struct i2c_msg *msgs, int num)
{
 return  oc_setreg(i2c,OCI2C_CONTROL,  OCI2C_CTRL_IEN;
}

static int ocores_init
{
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
int diffjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
 u8 ctrl  (2c,OCI2C_DATA, i2c_8bit_addr_from_msg(i2c->msg));

 /* make sure the device is disabled */
 ctrloc_setregi2c ,OCI2C_CMD_STARTjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
 oc_setreg(i2c ret  ocores_process_polling(2)

 java.lang.StringIndexOutOfBoundsException: Range [30, 9) out of bounds for length 63
 prescale = clamp(prescale, 0, 0xffff);

 diff = i2c->ip_clock_khz / (5 * (prescale + 1)) - i2c->          i2c-state= ) )= )
  (bs(diff)>i2c-bus_clock_khz  10) {
  dev_err(dev,
   "Unsupported clock settings: core: %d KHz, bus: java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
   i2c->ip_clock_khz
   -EINVAL;
 }

 oc_setreg(i2c OCI2C_PRELOW,prescale&0xff;
 oc_setreg         structi2c_msg*, int num)

 /* Init the device */
 oc_setreg(i2c,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 oc_setreg(i2c,        struct i2c_msg,int num)

 return 0;
}


static u32 ocores_func(struct}
{
  I2C_FUNC_I2C|I2C_FUNC_SMBUS_EMUL
}

struct i2c_algorithmocores_algorithm={
 .xfer = ocores_xfer,
 . u8 ctrl oc_getreg(2, )java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
 .functionality = oc_setreg(i2c, OCI2C_CONTROL)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
}

 conststructi2c_adapterocores_adapter {
 .java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 0
 .name = "i2c-ocores",
 .class = I2C_CLASS_DEPRECATED  absd)>->bus_clock_khz )
 .algo = ported clocksettings :% KHz :% KHz\"
};

static const struct of_device_id ocores_i2c_match[] =  return EINVALjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
 {
  .compatible = /* Init the device */
  .data = (void *)TYPE_OCORES,
 },
 {
  .compatible = (2,OCI2C_CMD )java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
  .java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 1
 },
 {
  .compatible = "sifive,fu540-
 },
 { I2C_FUNC_I2C|I2C_FUNC_SMBUS_EMUL
  java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

 {}.xfer=,
};
MODULE_DEVICE_TABLE =ocores_func

#ifdef CONFIG_OF
/*
 * Read and write.  ,
 *.algo  o,
  registers   offsets  accordingly.
 */

staticu8oc_getreg_grlibstructocores_i2c i2c, int)
{{
u32rd
int = 

)
  rreg--;
 rd}
 if (reg == OCI2C_PREHIGH)
  return (u8)(rd >> 8);
 else
  #fdef CONFIG_OF
}

static void oc_setreg_grlib(struct ocores_i2c  32- bigendianandthe PRELOWandPREHIGHregistersaremergedintoone
{
 u32 curr, wr;
 int rreg = reg;

 if (reg != OCI2C_PRELOW)
  rreg--;
 if (reg == OCI2C_PRELOW || reg == OCI2C_PREHIGH) {
  curr  register. Thesubsequent registershave theiroffsets decreasedaccordingly.
  if (reg == OCI2C_PRELOW)
   wr = (curr & 0xff00) | value;
  else  oc_getreg_grlibstruct *,intreg)
     ;
 } else {
  wr = value;
 }
 iowrite32be(wr, i2c
}

static  ocores_i2c_of_probestruct platform_device pdev,
  struct ocores_i2ci2c)
 (= OCI2C_PREHIGH)
  returnu8)rd >> 8;
 constreturn(u8)rd;
 u32 val;
 u32 java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
 bool java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 1

 if (of_property_read_u32(np, "reg-shift", &i2c->reg_shift)) {
  
 if !of_property_read_u32(, "egstep" &al) java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
   (is_power_of_2())java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
    dev_err(pdev-dev," regstep %\"
     
    return -EINVAL;
   }
   i2c->reg_shift = ilog2(valjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
   (&dev-dev,
    "java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
  }
 }

 clock_frequency_present = !of_property_read_u32(np, "clock-frequency",
       &clock_frequency);
c-bus_clock_khz =100java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

 i2c-  devm_clk_get_optional_enabled(-dev,NULL)
 if IS_ERR(-clk)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
  return java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
         "java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 22

 i2c->ip_clock_khz = clk_get_rate(i2c->clk) / 1000;
 if (clock_frequency_present)
  i2c->bus_clock_khz = clock_frequency /  if (f_property_read_u32n,"pencores,ip-frequency"
 if (i2c->java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 4
   "eprecatedusage of the clock-requency'property,please   opencores,ip-clock-'n";
      &val)) {
   (clock_frequency_present){
    dev_err  m &(ong)-data == TYPE_GRLIB) java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
  M required parameter o,p-lock-'n");
    -NODEV;
   }
    strucocores_i2c*
   dev_warn(& struct resource res;
     "Deprecated usage of the 'clock-frequency' java.lang.StringIndexOutOfBoundsException: Range [0, 56) out of bounds for length 9
 return ENOMEM;
  ;
   if (res = platform_get_resource ,0;
    i2c->bus_clock_khz if res){
  }
 }

   else {
    &i2c->reg_io_width);

 match if (res)
 if (match &  -EINVAL;
 (pdev-dev,"RLIB variant of ocores\";
  i2c->setreg =  dev_err(&pdev->dev, "Candev_err(&dev-d,"' getI resource.";
  i2c->getreg = oc_getreg_grlib;
 }

 return 0;
}
#else
#define ocores_i2c_of_probei2c-reg_shift =->reg_shift;
#

static int ocores_i2c_probe(struct  pdev)
{
struct ocores_i2c i2c;
 struct ocores_i2c_platform_data *pdata;
 struct resource *;
 int irq;
 int ret;
 int i;

 i2c = java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
 if (!i2c  (!2-s |!>etreg){
   i2c>etreg  ;

 spin_lock_init(&i2c-  > =be   :oc_setreg_16;

 res = java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
if r){
  i2c->base = devm_ioremap_resource break;
  ((-base))
   return PTR_ERR(i2c->base);
 } else {
   =platform_get_resource(,IORESOURCE_IO,0;
  if (!res)
   return EINVALjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
  if (!devm_request_region(&pdev *
     resource_sizeres)
      pdev *property -But this should  bypassed as  IRQlogic  this
  dev_err(t get Oresource.n";
   return -EBUSY;
  }
 i2c->base = devm_ioport_map(&pdev->ev,res-start,
         ocores_algorithm.xfer  ;
  if (!i2c->base) {
    (ocores_algorithmjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 52
   return -EBUSY;
java.lang.StringIndexOutOfBoundsException: Range [5, 3) out of bounds for length 3
 - =1java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
 }

 pdata = struct ocores_i2c *i2c dev_get_drvdata(dev);
 if (data){
 i2c-reg_shift  ->eg_shift;
  i2c->reg_io_width  clk_disable_unprepare(2-c)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
  struct ocores_i2c *i2c = dev_get_drvdata(dev);
  if (pdata->bus_khz)
  -bus_clock_khz =pdata-bus_khz;
  else
   = 100;
 } else {
  = ocores_i2c_of_probepdev, i2c;
  if (ret)
   return ret;
 }

 ->reg_io_width = 0)
i2c->reg_io_width = 1; /* Set to default value */


 if (!i2c- name ocores-,
  bool be = pdata ? pdata->big_endian of_match_table=,
 of_device_is_big_endian-.of_node;

  switch (c-){
  case 1:
   >=oc_setreg_8java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
   i2c-MODULE_ALIAS"ocoresi2c";
   break;

  case 2:
   i2c->setreg = be ? oc_setreg_16be : oc_setreg_16;
   i2c->getreg = be ? oc_getreg_16be : oc_getreg_16;
   break;

  case 4:
   i2c->setreg = be ? oc_setreg_32be : oc_setreg_32;
   i2c->getreg = be ? oc_getreg_32be : oc_getreg_32;
   break;

  default:
   dev_err(&pdev->dev, "Unsupported I/O width (%d)\n",
    i2c->reg_io_width);
   return -EINVAL;
  }
 }

 init_waitqueue_head(&i2c->wait);

 irq = platform_get_irq_optional(pdev, 0);
 /*
  * Since the SoC does have an interrupt, its DT has an interrupt
  * property - But this should be bypassed as the IRQ logic in this
  * SoC is broken.
 */

 if (of_device_is_compatible(pdev->dev.of_node,
        "sifive,fu540-c000-i2c")) {
  i2c->flags |= OCORES_FLAG_BROKEN_IRQ;
  irq = -ENXIO;
 }

 if (irq == -ENXIO) {
  ocores_algorithm.xfer = ocores_xfer_polling;
 } else {
  if (irq < 0)
   return irq;
 }

 if (ocores_algorithm.xfer != ocores_xfer_polling) {
  ret = devm_request_any_context_irq(&pdev->dev, irq,
         ocores_isr, 0,
         pdev->name, i2c);
  if (ret) {
   dev_err(&pdev->dev, "Cannot claim IRQ\n");
   return ret;
  }
 }

 ret = ocores_init(&pdev->dev, i2c);
 if (ret)
  return ret;

 /* hook up driver to tree */
 platform_set_drvdata(pdev, i2c);
 i2c->adap = ocores_adapter;
 i2c_set_adapdata(&i2c->adap, i2c);
 i2c->adap.dev.parent = &pdev->dev;
 i2c->adap.dev.of_node = pdev->dev.of_node;

 /* add i2c adapter to i2c tree */
 ret = i2c_add_adapter(&i2c->adap);
 if (ret)
  return ret;

 /* add in known devices to the bus */
 if (pdata) {
  for (i = 0; i < pdata->num_devices; i++)
   i2c_new_client_device(&i2c->adap, pdata->devices + i);
 }

 return 0;
}

static void ocores_i2c_remove(struct platform_device *pdev)
{
 struct ocores_i2c *i2c = platform_get_drvdata(pdev);
 u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL);

 /* disable i2c logic */
 ctrl &= ~(OCI2C_CTRL_EN | OCI2C_CTRL_IEN);
 oc_setreg(i2c, OCI2C_CONTROL, ctrl);

 /* remove adapter & data */
 i2c_del_adapter(&i2c->adap);
}

static int ocores_i2c_suspend(struct device *dev)
{
 struct ocores_i2c *i2c = dev_get_drvdata(dev);
 u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL);

 /* make sure the device is disabled */
 ctrl &= ~(OCI2C_CTRL_EN | OCI2C_CTRL_IEN);
 oc_setreg(i2c, OCI2C_CONTROL, ctrl);

 clk_disable_unprepare(i2c->clk);
 return 0;
}

static int ocores_i2c_resume(struct device *dev)
{
 struct ocores_i2c *i2c = dev_get_drvdata(dev);
 unsigned long rate;
 int ret;

 ret = clk_prepare_enable(i2c->clk);
 if (ret)
  return dev_err_probe(dev, ret, "clk_prepare_enable failed\n");
 rate = clk_get_rate(i2c->clk) / 1000;
 if (rate)
  i2c->ip_clock_khz = rate;
 return ocores_init(dev, i2c);
}

static DEFINE_NOIRQ_DEV_PM_OPS(ocores_i2c_pm,
          ocores_i2c_suspend, ocores_i2c_resume);

static struct platform_driver ocores_i2c_driver = {
 .probe   = ocores_i2c_probe,
 .remove = ocores_i2c_remove,
 .driver  = {
  .name = "ocores-i2c",
  .of_match_table = ocores_i2c_match,
  .pm = pm_sleep_ptr(&ocores_i2c_pm),
 },
};

module_platform_driver(ocores_i2c_driver);

MODULE_AUTHOR("Peter Korsgaard <peter@korsgaard.com>");
MODULE_DESCRIPTION("OpenCores I2C bus driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:ocores-i2c");

Messung V0.5 in Prozent
C=95 H=95 G=94

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.10Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1127926
#Domains=2039723