|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: j. @6 z0 ^$ g0 L( U#include <linux/init.h>
8 i; b8 n& n- y( I#include <linux/module.h>1 }& P; s9 {6 i( A
#include <linux/kernel.h>
6 J2 \+ f1 n/ k' o. ]3 n5 T#include <linux/types.h>
0 v8 ?' d( M, L6 H0 b; n6 B#include <linux/gpio.h>* e1 W6 ^2 K- Y6 {1 `7 v8 H
#include <linux/leds.h>; Z) @! ?0 T" f/ T& j, {# N
#include <linux/platform_device.h>: i4 c n, Z" s
4 U& y. ~1 B/ F
#include <asm/mach-types.h>
' U. L5 m0 m. C#include <asm/mach/arch.h>! u& m1 C; e( r* s% h1 U' z
#include <mach/da8xx.h>
. n3 z' }& @. t# ?" x#include <mach/mux.h>
6 Z7 p: r) a" I( I
E: `1 f8 j, B; V2 ?* m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 J/ @8 W7 `$ V( ^. F% S" u5 e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- {0 [( {) [4 W; s& f) J4 X
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- C* Z" [$ I8 H+ }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' R, T0 t- u8 ~; S; g6 S; F" v# z
( O. {6 V; f) P. N" _/* assign the tl som board LED-GPIOs*/8 ?6 d w* X+ O' c8 u/ C
static const short da850_evm_tl_user_led_pins[] = {' M/ `* w. u# k$ O3 m: D* K: M
/* These pins are definition at <mach/mux.h> file */+ m% {8 s0 G# K9 ]/ R; X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' a2 I" J2 b* P$ [8 j -1; S, x: u. o3 M5 a, n
};* _6 i; \$ d0 D2 k
9 ^4 S; z7 _7 S) }
static struct gpio_led da850_evm_tl_leds[] = {% j0 ^1 E8 |# x3 Q9 `
{
6 M7 t3 x. `1 T+ Z5 n .active_low = 0,
1 I& l- Q3 W9 L, K .gpio = DA850_USER_LED0,
6 s3 d) x% w1 c( L, w .name = "user_led0",
" V8 o* q4 Q" v# }# `' Q .default_trigger = "default-on",5 N% ?% M1 f' N6 W1 _2 G
},: q4 ^7 P1 u5 v: d2 r$ o
{
8 X W# `+ G- U7 Y .active_low = 0,
9 b% V5 ^7 V2 |) z3 y4 d) y1 r .gpio = DA850_USER_LED1,6 E1 l. L9 J4 @* k2 J2 B
.name = "user_led1",
. ~6 w4 O. y# `8 }6 [% n .default_trigger = "default-on",
1 \ \% g* ]: ^. y, @ },
/ e- }- e: q- ^% C; D( \- _& k {
7 }$ U- @7 f( N3 D+ X! s .active_low = 0,8 X1 P$ `5 v: [- j
.gpio = DA850_USER_LED2,
" T5 R4 A4 K' B- S/ k% ^ .name = "user_led2",
+ `0 y( E% d+ R .default_trigger = "default-on",
; ^2 N. v* ?5 z9 P },
% J; c. \: ~7 `7 z0 ~$ ]: A) ~ Q {
8 ?3 `2 `$ X& _, Q4 U4 ^; N .active_low = 0,8 R" Z- p! O9 v# ]8 h
.gpio = DA850_USER_LED3,
0 @0 F/ t& h; r2 B4 Y7 d1 R; E3 F/ I .name = "user_led3",3 I p1 d3 X8 w' x: X6 y
.default_trigger = "default-on",
: o P8 }( {" Y' x0 q+ ?3 F; r },
5 g& o. y* \8 D};" [, z9 w5 [/ U/ z- \* O) P3 V% I' ~' m
3 `- U% x& U* S+ L# I _. G# M' _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 q2 [7 p, g# {& O1 Z .leds = da850_evm_tl_leds,
2 @) M+ ]5 q N; i$ a5 U .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 K. N3 d1 z! U# l};
7 f, ^; K% q, |0 Z% m/ o' c% `8 x: ^' Y; I& o( x1 g; _5 T. c/ r# L$ ~+ A
static void led_dev_release(struct device *dev)8 \ m& U6 [! |: M3 C" o
{* s. p. z# X3 ]4 B4 |
};
7 f$ V5 a7 c( d1 Y) A9 R( A, L
6 R6 P/ X# ^2 z) n* V# Gstatic struct platform_device da850_evm_tl_leds_device = {
( F4 n# Q5 A ]+ c3 V .name = "leds-gpio",* W( r0 n! y# m$ h% a3 v5 V- z4 O
.id = 1,
3 h. b3 { m8 z0 s( c .dev = {
9 e2 @) b3 C$ U/ S. q, X, h1 [* B .platform_data = &da850_evm_tl_leds_pdata,9 i# M4 ]$ p; Y. f0 {5 y
.release = led_dev_release,
: |2 A! b. Z- c' e }
- X% r4 \* t4 t. U5 [$ j0 d};
& U% J* L( L& O" |" a+ o1 K0 q# W. o4 u4 R& I( X: U# J, F
static int __init led_platform_init(void)
8 ~, s7 E5 }$ g- `9 K7 q{5 o3 p& c: T, H) n4 }
int ret;
& U, g1 K- X3 \' }/ h$ l. |#if 0
' D: a( u: T2 @) M* F4 H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' B9 ~: C" }$ F if (ret)8 ]9 ]# Y1 L+ C* F d6 V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 x4 t/ ~& w3 e& `0 q "%d\n", ret);3 G' |9 P& X& u/ K$ `( M
#endif
6 M: `. o) [2 l" S+ I8 A: X7 | ret = platform_device_register(&da850_evm_tl_leds_device);5 P& @: k- r# A5 w) g- c9 }
if (ret)
/ \* Y5 ? d* J) D2 g pr_warning("Could not register som GPIO expander LEDS");
5 i$ Q& A1 a) Z: E. F else
7 S2 ]! U- z9 o; Q5 F# l printk(KERN_INFO "LED register sucessful!\n");/ W/ a7 N" N: w, t. b( U: _
7 p: S; |9 t/ K return ret;3 N1 u: H8 w! M4 g+ b) ^0 Z
}, b( E& _, ]) P& B/ n4 X- k( q
% ~( D6 m& X) Nstatic void __exit led_platform_exit(void)
7 Y* [4 |+ Y2 v V{
3 x4 u, }/ O: r" w y. i# {$ m platform_device_unregister(&da850_evm_tl_leds_device);3 U9 {0 g# z/ _" q; |
, c: L: h/ f; u! _* Y
printk(KERN_INFO "LED unregister!\n");9 {0 ?; E) [& l) d. N: f0 Z P
}4 @3 v" u8 c7 L- W! h& z |
. G- d# B* X/ I/ W" p# P
module_init(led_platform_init);+ O- |; H! t3 R7 f0 E, K
module_exit(led_platform_exit);
" Y- l7 D5 V! G1 O5 f& c" o3 @7 w, l: d- q! x. S& H; z
MODULE_DESCRIPTION("Led platform driver");
2 @! M. X' L9 YMODULE_AUTHOR("Tronlong");" g% U5 o8 }3 R
MODULE_LICENSE("GPL");; l c" m+ w; E1 N- K# {! ^
9 Z2 q+ O8 e; S. |, j3 b* @ |
|