arch/arm/mach-omap1/timer.c

Source file repositories/reference/linux-study-clean/arch/arm/mach-omap1/timer.c

File Facts

System
Linux kernel
Corpus path
arch/arm/mach-omap1/timer.c
Extension
.c
Size
3732 bytes
Lines
166
Domain
Architecture Layer
Bucket
arch/arm
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (i) {
		case 1:
			base = OMAP1610_GPTIMER1_BASE;
			irq = INT_1610_GPTIMER1;
			break;
		case 2:
			base = OMAP1610_GPTIMER2_BASE;
			irq = INT_1610_GPTIMER2;
			break;
		case 3:
			base = OMAP1610_GPTIMER3_BASE;
			irq = INT_1610_GPTIMER3;
			break;
		case 4:
			base = OMAP1610_GPTIMER4_BASE;
			irq = INT_1610_GPTIMER4;
			break;
		case 5:
			base = OMAP1610_GPTIMER5_BASE;
			irq = INT_1610_GPTIMER5;
			break;
		case 6:
			base = OMAP1610_GPTIMER6_BASE;
			irq = INT_1610_GPTIMER6;
			break;
		case 7:
			base = OMAP1610_GPTIMER7_BASE;
			irq = INT_1610_GPTIMER7;
			break;
		case 8:
			base = OMAP1610_GPTIMER8_BASE;
			irq = INT_1610_GPTIMER8;
			break;
		default:
			/*
			 * not supposed to reach here.
			 * this is to remove warning.
			 */
			return -EINVAL;
		}

		pdev = platform_device_alloc("omap_timer", i);
		if (!pdev) {
			pr_err("%s: Failed to device alloc for dmtimer%d\n",
				__func__, i);
			return -ENOMEM;
		}

		memset(res, 0, 2 * sizeof(struct resource));
		res[0].start = base;
		res[0].end = base + 0x46;
		res[0].flags = IORESOURCE_MEM;
		res[1].start = irq;
		res[1].end = irq;
		res[1].flags = IORESOURCE_IRQ;
		ret = platform_device_add_resources(pdev, res,
				ARRAY_SIZE(res));
		if (ret) {
			dev_err(&pdev->dev, "%s: Failed to add resources.\n",
				__func__);
			goto err_free_pdev;
		}

		pdata = kzalloc_obj(*pdata);
		if (!pdata) {
			ret = -ENOMEM;
			goto err_free_pdata;
		}

		pdata->set_timer_src = omap1_dm_timer_set_src;
		pdata->timer_capability = OMAP_TIMER_ALWON |
				OMAP_TIMER_NEEDS_RESET | OMAP_TIMER_HAS_DSP_IRQ;

		ret = platform_device_add_data(pdev, pdata, sizeof(*pdata));
		if (ret) {
			dev_err(&pdev->dev, "%s: Failed to add platform data.\n",
				__func__);
			goto err_free_pdata;
		}

		ret = platform_device_add(pdev);
		if (ret) {
			dev_err(&pdev->dev, "%s: Failed to add platform device.\n",
				__func__);
			goto err_free_pdata;
		}

		dev_dbg(&pdev->dev, " Registered.\n");
	}

Annotation

Implementation Notes