|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* W- E: T; ]; f" H' p4 T7 X& Z- I* P#include <linux/init.h>
6 {, E5 f/ |! f: Y' Y#include <linux/module.h>
! F5 m% j! e0 Q. a: F#include <linux/kernel.h>! E0 ?9 S. M! F0 ?
#include <linux/types.h>. ~6 u3 x) Z! ?* t7 q
#include <linux/gpio.h>
6 v7 g% i6 O q; k) P( I#include <linux/leds.h>" @* ]1 A) v/ I% {! p" L6 m1 U4 Y; F
#include <linux/platform_device.h>
6 U9 @: x' W. Y# i- P, J2 c
) j+ `2 H7 O, c#include <asm/mach-types.h>$ k) n1 m _# l# r, H! h) {
#include <asm/mach/arch.h>
8 M6 b6 X2 I9 t+ m9 ?#include <mach/da8xx.h>" M. y/ g2 w! Z' ]& M
#include <mach/mux.h>
! C5 y% _* U/ F' Z# N, I1 q5 W* F; U# N) F
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 Z, O! }$ w# U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 c; H" n5 Z1 S% |; K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 H1 U; o* H3 A! h8 }* o4 c9 E0 o4 X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% U0 Q. D f4 @9 t4 n2 f) X
9 P, k' m1 s7 L. @% a. y" j! T
/* assign the tl som board LED-GPIOs*/
/ H! P2 v; q# K4 ostatic const short da850_evm_tl_user_led_pins[] = {
( B7 q9 p8 M/ `: \8 g /* These pins are definition at <mach/mux.h> file */2 I; d9 _, z1 [6 I, @: {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" L1 D9 G: \' D0 n -1
* C, K' F; v* R};8 r$ e/ e+ |% W* ]; ]! x
$ v* y5 d' l- V) p% J! @
static struct gpio_led da850_evm_tl_leds[] = {
, Q# `8 d4 ]. F {
/ F$ x2 h" \8 i .active_low = 0,
4 r: @6 e4 O9 r1 w- g2 r! z .gpio = DA850_USER_LED0,
7 n5 ~6 y, b+ C- x- X: H5 G9 F% m& a .name = "user_led0",* G) G2 E" Q3 Q% B" \+ Q3 B
.default_trigger = "default-on",
9 p" p$ ?# H, H. w( g7 ^4 P },1 |( R1 n$ q$ J
{
7 e; H7 o1 ~4 ~ .active_low = 0,% M) z5 C9 W% R$ o5 }
.gpio = DA850_USER_LED1,
. v a* I: P! e- S% C. L( K .name = "user_led1",
" s, q. h* j) }3 P& C2 ` .default_trigger = "default-on",
* N$ `! Y0 Q: X7 g },
( F7 r# S2 k1 i( ?8 D& R* } {# B/ A% k5 U6 H4 i8 n. f
.active_low = 0,
9 F9 l/ l# n+ p# b7 F3 {4 e% m .gpio = DA850_USER_LED2,5 V2 o5 `& R) t3 F
.name = "user_led2",
5 Y* D5 e! v6 C6 S4 j) P$ `0 y .default_trigger = "default-on",
& A! b" c- ]! Q0 X( R8 w },. L; s# |# C8 E2 z
{0 Z' S) C" }( i& G
.active_low = 0,. t5 K5 v6 P+ N: s2 `
.gpio = DA850_USER_LED3,5 ?: \8 n, e; e, _& Q3 X1 W
.name = "user_led3",3 F, C! k: a( e6 L0 k& ^: l( H
.default_trigger = "default-on",5 ^ i) L0 C5 G: u! O
},
6 C, x4 `7 i" a. V* l};' f" A1 t2 @4 g
. X% [ m3 B) @1 S Y, V) u4 Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% @- Q9 D, z3 c3 L2 c2 z
.leds = da850_evm_tl_leds,
" B: h1 L) [( c$ T, R8 A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; q% U& W% }; o+ ^};
7 F. ^4 @" N. z, S( d$ V5 F
5 s% B( v( E" W9 \* q. j& `8 ustatic void led_dev_release(struct device *dev)
: \. O' V+ g7 N L- u7 t{
* K0 g8 x$ @. [( f};' M. i, A, {+ n- d
$ s2 v0 t4 [/ Y3 d& F
static struct platform_device da850_evm_tl_leds_device = {
) w0 H2 m, B3 w5 Y$ z; k .name = "leds-gpio",
9 E- A8 |1 D( g8 g7 |. u, f# m8 x W .id = 1,
. P- S w% J- d2 @0 Y) w* y. S4 s! u .dev = {( }$ ~+ K7 t L( ]$ i$ X1 F$ O0 r
.platform_data = &da850_evm_tl_leds_pdata,+ x. @/ F! w. w4 b& Y$ ~" p/ o5 p
.release = led_dev_release,
5 u2 U/ g. \9 |' }, s! w0 z }
% [7 E3 @) Y3 P$ E};
# [7 A$ A/ n! Q: R ^; ] E; {9 t# M" d: n4 |7 Q% f$ U
static int __init led_platform_init(void)# T' N0 y* R# _; F
{) o. D% N: I& q) S$ ~3 o! c
int ret;
2 Y. B+ L. \, ~" C/ X) N! ^#if 0
* C$ c" ?( @1 L- r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ l& P: j- H3 ]& E
if (ret)
q5 e! u) o2 Z9 b' X6 @3 y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- `/ D+ s1 z H! ` ?, n "%d\n", ret);
2 @2 \$ M0 j& n( k6 c#endif( l9 c( ^3 O/ J6 a% r5 a7 w* ~5 J
ret = platform_device_register(&da850_evm_tl_leds_device);
& Z. f' B d0 k( c. k; W/ O if (ret)$ E" ?3 _0 o" u& N; X/ A
pr_warning("Could not register som GPIO expander LEDS");
, J9 e5 s/ E1 @) n# } else6 e# |: H: O; m* u: T& H
printk(KERN_INFO "LED register sucessful!\n");" `7 M. O: \! u% x2 S3 p! _
5 ]- d# F; p$ D! ~% B8 m
return ret;
" U+ j( O. R9 v1 C}
! P u6 O, l, M2 \/ f7 L% ]5 F+ w) s" \& g
static void __exit led_platform_exit(void)1 A) o2 f0 g2 y' o* R) Y Z
{
; C& v/ R: X' ?$ G platform_device_unregister(&da850_evm_tl_leds_device);* B9 [+ \; G$ c9 R8 X5 F7 K1 _9 \3 `
& k/ e& m6 p7 l5 n) K# o printk(KERN_INFO "LED unregister!\n");
( R+ l9 Z7 Q6 N4 `}# [0 B( J( h: |# X. e: P- l
0 ~' B- P/ E# l, k O
module_init(led_platform_init);+ u6 B- ~* ?1 M$ u8 a7 }2 I- G' ?# b' `
module_exit(led_platform_exit);- B! h% o" a+ f/ j2 V
5 j) Y5 g! d' j1 A( tMODULE_DESCRIPTION("Led platform driver");
9 ?9 J5 d, \* Z I6 p3 E& T4 L# EMODULE_AUTHOR("Tronlong");# D+ O: `, O& @5 B& |1 D
MODULE_LICENSE("GPL");
# g E4 y8 q8 ~1 E N1 p0 D7 Z8 P% ]8 p$ Q
|
|