int nomac_dev_init(struct rtnet_device *rtdev, struct nomac_priv *nomac) { char *pos; nomac->api_device.struct_version = RTDM_DEVICE_STRUCT_VER; nomac->api_device.device_flags = RTDM_NAMED_DEVICE; nomac->api_device.context_size = 0; strcpy(nomac->api_device.device_name, "NOMAC"); for (pos = rtdev->name + strlen(rtdev->name) - 1; (pos >= rtdev->name) && ((*pos) >= '0') && (*pos <= '9'); pos--); strncat(nomac->api_device.device_name+5, pos+1, IFNAMSIZ-5); nomac->api_device.open_nrt = (rtdm_open_handler_t)nomac_dev_openclose; nomac->api_device.ops.close_nrt = (rtdm_close_handler_t)nomac_dev_openclose; nomac->api_device.ops.ioctl_rt = nomac_dev_ioctl; nomac->api_device.ops.ioctl_nrt = nomac_dev_ioctl; nomac->api_device.proc_name = nomac->api_device.device_name; nomac->api_device.device_class = RTDM_CLASS_RTMAC; nomac->api_device.device_sub_class = RTDM_SUBCLASS_UNMANAGED; nomac->api_device.driver_name = "nomac"; nomac->api_device.driver_version = RTNET_RTDM_VER; nomac->api_device.peripheral_name = "NoMAC API"; nomac->api_device.provider_name = rtnet_rtdm_provider_name; return rtdm_dev_register(&nomac->api_device); }
static int __init mpu9150_i2c_init_driver(void) { int retval; if((retval = rtdm_dev_register(&mpu9150_driver)) < 0) return retval; return i2c_add_driver( &mpu9150_i2c_driver ); }
int cobalt_memdev_init(void) { int ret; ret = cobalt_umm_init(&cobalt_kernel_ppd.umm, CONFIG_XENO_OPT_SHARED_HEAPSZ * 1024, NULL); if (ret) return ret; cobalt_umm_set_name(&cobalt_kernel_ppd.umm, "shared heap"); nkvdso = cobalt_umm_alloc(&cobalt_kernel_ppd.umm, sizeof(*nkvdso)); if (nkvdso == NULL) { ret = -ENOMEM; goto fail_vdso; } init_vdso(); ret = rtdm_dev_register(umm_devices + UMM_PRIVATE); if (ret) goto fail_private; ret = rtdm_dev_register(umm_devices + UMM_SHARED); if (ret) goto fail_shared; ret = rtdm_dev_register(&sysmem_device); if (ret) goto fail_sysmem; return 0; fail_sysmem: rtdm_dev_unregister(umm_devices + UMM_SHARED); fail_shared: rtdm_dev_unregister(umm_devices + UMM_PRIVATE); fail_private: cobalt_umm_free(&cobalt_kernel_ppd.umm, nkvdso); fail_vdso: cobalt_umm_destroy(&cobalt_kernel_ppd.umm); return ret; }
int nomac_dev_init(struct rtnet_device *rtdev, struct nomac_priv *nomac) { char *pos; strcpy(nomac->device_name, "NOMAC"); for (pos = rtdev->name + strlen(rtdev->name) - 1; (pos >= rtdev->name) && ((*pos) >= '0') && (*pos <= '9'); pos--); strncat(nomac->device_name+5, pos+1, IFNAMSIZ-5); nomac->api_driver = nomac_driver; nomac->api_device.driver = &nomac->api_driver; nomac->api_device.label = nomac->device_name; return rtdm_dev_register(&nomac->api_device); }
int __init __rtdmtest_init(void) { int err; do { snprintf(device.device_name, RTDM_MAX_DEVNAME_LEN, "rttest%d", start_index); err = rtdm_dev_register(&device); printk("%s: registering device %s, err=%d\n", __FUNCTION__, device.device_name, err); start_index++; } while (err == -EEXIST); return err; }
/** Initialize an RTDM device. * * \return Zero on success, otherwise a negative error code. */ int ec_rtdm_dev_init( ec_rtdm_dev_t *rtdm_dev, /**< EtherCAT RTDM device. */ ec_master_t *master /**< EtherCAT master. */ ) { int ret; rtdm_dev->master = master; rtdm_dev->dev = kzalloc(sizeof(struct rtdm_device), GFP_KERNEL); if (!rtdm_dev->dev) { EC_MASTER_ERR(master, "Failed to reserve memory for RTDM device.\n"); return -ENOMEM; } rtdm_dev->dev->struct_version = RTDM_DEVICE_STRUCT_VER; rtdm_dev->dev->device_flags = RTDM_NAMED_DEVICE; rtdm_dev->dev->context_size = sizeof(ec_rtdm_context_t); snprintf(rtdm_dev->dev->device_name, RTDM_MAX_DEVNAME_LEN, "EtherCAT%u", master->index); rtdm_dev->dev->open_nrt = ec_rtdm_open; rtdm_dev->dev->ops.close_nrt = ec_rtdm_close; rtdm_dev->dev->ops.ioctl_rt = ec_rtdm_ioctl; rtdm_dev->dev->ops.ioctl_nrt = ec_rtdm_ioctl; rtdm_dev->dev->device_class = RTDM_CLASS_EXPERIMENTAL; rtdm_dev->dev->device_sub_class = 222; rtdm_dev->dev->driver_name = "EtherCAT"; rtdm_dev->dev->driver_version = RTDM_DRIVER_VER(1, 0, 2); rtdm_dev->dev->peripheral_name = rtdm_dev->dev->device_name; rtdm_dev->dev->provider_name = "EtherLab Community"; rtdm_dev->dev->proc_name = rtdm_dev->dev->device_name; rtdm_dev->dev->device_data = rtdm_dev; /* pointer to parent */ EC_MASTER_INFO(master, "Registering RTDM device %s.\n", rtdm_dev->dev->driver_name); ret = rtdm_dev_register(rtdm_dev->dev); if (ret) { EC_MASTER_ERR(master, "Initialization of RTDM interface failed" " (return value %i).\n", ret); kfree(rtdm_dev->dev); } return ret; }
int __init __switchtest_init(void) { int err; err = rtdm_nrtsig_init(&rtswitch_wake_utask, rtswitch_utask_waker, NULL); if (err) return err; do { snprintf(device.device_name, RTDM_MAX_DEVNAME_LEN, "rttest%d", start_index); err = rtdm_dev_register(&device); start_index++; } while (err == -EEXIST); return err; }
int a4l_register(void) { int i, ret = 0; for (i = 0; i < A4L_NB_DEVICES && ret == 0; i++) { /* Sets the device name through which user process can access the Analogy layer */ snprintf(rtdm_devs[i].device_name, RTDM_MAX_DEVNAME_LEN, "analogy%d", i); rtdm_devs[i].proc_name = rtdm_devs[i].device_name; /* To keep things simple, the RTDM device ID is the Analogy device index */ rtdm_devs[i].device_id = i; ret = rtdm_dev_register(&(rtdm_devs[i])); } return ret; }
int tdma_dev_init(struct rtnet_device *rtdev, struct tdma_priv *tdma) { char *pos; tdma->api_device.struct_version = RTDM_DEVICE_STRUCT_VER; tdma->api_device.device_flags = RTDM_NAMED_DEVICE; tdma->api_device.context_size = 0; strcpy(tdma->api_device.device_name, "TDMA"); for (pos = rtdev->name + strlen(rtdev->name) - 1; (pos >= rtdev->name) && ((*pos) >= '0') && (*pos <= '9'); pos--); strncat(tdma->api_device.device_name+4, pos+1, IFNAMSIZ-4); tdma->api_device.open_rt = (int (*)(struct rtdm_dev_context *, int, int))tdma_dev_openclose; tdma->api_device.open_nrt = (int (*)(struct rtdm_dev_context *, int, int))tdma_dev_openclose; tdma->api_device.ops.close_rt = (int (*)(struct rtdm_dev_context *, int))tdma_dev_openclose; tdma->api_device.ops.close_nrt = (int (*)(struct rtdm_dev_context *, int))tdma_dev_openclose; tdma->api_device.ops.ioctl_rt = tdma_dev_ioctl; tdma->api_device.ops.ioctl_nrt = tdma_dev_ioctl; tdma->api_device.proc_name = tdma->api_device.device_name; tdma->api_device.device_class = RTDM_CLASS_RTMAC; tdma->api_device.device_sub_class = RTDM_SUBCLASS_TDMA; tdma->api_device.driver_name = "RTmac/TDMA (RTnet " RTNET_PACKAGE_VERSION ")"; tdma->api_device.peripheral_name = "TDMA API"; tdma->api_device.provider_name = "(C) 2002-2004 RTnet Development Team, http://rtnet.sf.net"; return rtdm_dev_register(&tdma->api_device); }
/* Module entry */ int __init moduleInit( void) { int retval; uint32_t i; retval = 0; LOG(DEF_DRV_DESCRIPTION " v%d.%d.%d", DEF_DRV_VERSION_MAJOR, DEF_DRV_VERSION_MINOR, DEF_DRV_VERSION_PATCH); for (i = 0u; i < CFG_MAX_DEVICES; i++) { if (TRUE == portDevIsReady(i)) { struct rtdm_device * dev; int32_t ret; LOG_INFO("building SPI device: %d", i); ret = portDevCreate( &dev, &DevTemplate, i); if (0 != ret) { LOG_ERR("failed to build device: %d, err: %d", i, -ret); retval = (int)ret; break; } portDevEnable( dev); LOG_INFO("initializing SPI device: %d", i); ret = lldDevInit( dev); if (0 != ret) { LOG_ERR("failed to initialize device: %d, err: %d", i, -ret); portDevDisable( dev); portDevDestroy( dev); retval = (int)ret; break; } LOG_INFO("registering SPI device: %d", i); retval = rtdm_dev_register( dev); if (0 != retval) { LOG_ERR("failed to register device: %d, err: %d", i, -retval); lldDevTerm( dev); portDevDisable( dev); portDevDestroy( dev); break; } LOG_INFO("SPI device %d successfully brought online", i); Devs[i] = dev; } else { LOG_DBG("skipping SPI device: %d", i); } } return (retval); }
static int uart_omap_probe(struct platform_device *pdev) { printk("omap_i2c_probe started\n"); struct uart_omap_port *up; struct resource *mem,*irq; struct omap_uart_port_info *omap_up_info=pdev->dev.platform_data; int ret; struct rtdm_device *rdev; void __iomem *mem_1; int retval; if(pdev->dev.of_node) omap_up_info = of_get_uart_port_info(&pdev->dev); mem = platform_get_resource(pdev,IORESOURCE_MEM,0); if(!mem) { dev_err(&pdev->dev,"no mem resource\n"); return -ENODEV; } printk("platform_get_resource for mem\n"); irq = platform_get_resource(pdev,IORESOURCE_IRQ,0); if(!irq) { dev_err(&pdev->dev,"no irq resource\n"); return -ENODEV; } printk("platform_get_resource for irq\n"); if(!devm_request_mem_region(&pdev->dev,mem->start,resource_size(mem),pdev->dev.driver->name)) { dev_err(&pdev->dev,"memory region already claimed\n"); return -EBUSY; } printk("mem->start=%x\n",mem->start); printk("irq->start=%x\n",irq->start); if ( gpio_is_valid(omap_up_info->DTR_gpio) && omap_up_info->DTR_present) { ret = gpio_request(omap_up_info->DTR_gpio, "omap-serial"); printk("gpio_request\n"); if (ret < 0) return ret; ret = gpio_direction_output(omap_up_info->DTR_gpio,omap_up_info->DTR_inverted); printk("gpio_direction_output\n"); if (ret < 0) return ret; } printk("gpio_is_valid\n"); up = devm_kzalloc(&pdev->dev, sizeof(*up), GFP_KERNEL); if (!up) return -ENOMEM; printk("Local struct up=%x\n",up); rtdm_printk("clock enabling.......UART4\n"); mem_1 = ioremap(SOC_PRCM_REGS, SOC_PRCM_SIZE); if(!mem) { printk (KERN_ERR "HI: ERROR: Failed to remap memory for GPIO Bank 2 IRQ pin configuration.\n"); return 0; } // retval=ioread32(mem_1 + 0x78); // rtdm_printk("value of clock i2c enable retval=%d\n",retval); iowrite32(CM_PER_UART4_CLKCTRL , mem_1 + 0x78); // retval = ioread32(CM_PER_UART4_CLKCTRL + 0x78); // rtdm_printk("value of clock i2c enable retval=%d\n",retval); rtdm_printk("clock enable for UART4\n"); rdev=kzalloc(sizeof(struct rtdm_device),GFP_KERNEL); rdev = &up->rtdm_dev; memcpy(rdev, &uart_device, sizeof(struct rtdm_device)); ret=rtdm_dev_register(rdev); if(ret<0) { printk("RTDM device not registered\n"); } rdev->device_data = devm_kzalloc(&pdev->dev, sizeof(MY_DEV), GFP_KERNEL); rdev->device_data = up; printk("RTDM driver register\n"); if (gpio_is_valid(omap_up_info->DTR_gpio) && omap_up_info->DTR_present) { up->DTR_gpio = omap_up_info->DTR_gpio; up->DTR_inverted = omap_up_info->DTR_inverted; printk("DTR gpio valid\n"); } else up->DTR_gpio = -EINVAL; up->DTR_active = 0; up->dev = &pdev->dev; up->irq = irq->start; up->regshift = 2; up->fifosize = 64; if (pdev->dev.of_node) { up->line = of_alias_get_id(pdev->dev.of_node, "serial"); printk("pdev->dev.of_node\n"); } else { up->line = pdev->id; printk("pdev->id\n"); } if (up->line < 0) { dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n",up->line); ret = -ENODEV; // goto err_port_line; } up->pins = devm_pinctrl_get_select_default(&pdev->dev); if (IS_ERR(up->pins)) { dev_warn(&pdev->dev, "did not get pins for uart%i error: %li\n",up->line, PTR_ERR(up->pins)); up->pins = NULL; } printk("devm_pinctrl_get_select_default\n"); sprintf(up->name, "OMAP UART%d", up->line); up->mapbase = mem->start; up->membase = devm_ioremap(&pdev->dev,mem->start,resource_size(mem));//what does ioremap do???? read about it if (!up->membase) { dev_err(&pdev->dev, "can't ioremap UART\n"); ret = -ENOMEM; // goto err_ioremap; } up->flags = omap_up_info->flags; up->uartclk = omap_up_info->uartclk; printk("clock freq=%d\n",up->uartclk); if(!up->uartclk) { up->uartclk = DEFAULT_CLK_SPEED; dev_warn(&pdev->dev, "No clock speed specified: using default:""%d\n", DEFAULT_CLK_SPEED); } up->latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE; up->calc_latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE; platform_set_drvdata(pdev, up); omap_serial_fill_features_erratas(up); return 0; //err_unuse_clocks: // omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); //err_free_mem: // platform_set_drvdata(pdev, NULL); // return r; }
/** * This function is called when the module is loaded * * It simply registers the RTDM device. * */ int __init simple_rtdm_init(void) { return rtdm_dev_register(&device); }