|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 W7 g. c- D4 Z$ P2 h9 `6 T) I9 N. R#include <linux/init.h>" Y8 n8 c& e% Q; r, h
#include <linux/module.h>' V! N- ?; V% i( u; J: L
#include <linux/kernel.h># e$ w. z7 z7 e8 o" v: K5 }
#include <linux/types.h>
8 Z7 k8 i8 R- A: G9 Q#include <linux/gpio.h> n2 a- A; \- W: A4 i4 [- o2 q
#include <linux/leds.h>
7 F) S0 q$ j# H% a/ V#include <linux/platform_device.h>' I# d) K8 y6 {1 }* w! Y( Q$ X& H
* G3 y! T' R# Q! f' T/ S g+ ~
#include <asm/mach-types.h>
) V. Z3 H" x+ q1 Q5 U1 s#include <asm/mach/arch.h>% i8 Y6 _+ }) b" u) q* B2 G- N1 C
#include <mach/da8xx.h>
% v# D4 ~% _ q% k+ t#include <mach/mux.h>
2 P) v ^3 ]; t6 Z- [! S, B, r3 r m) o- x5 X7 C- i
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! k3 a8 Z b( J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) L% [: C2 E% C/ _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), ]) L5 _- X @+ J+ E# y" Q! T+ I, ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
@8 r8 d( \8 i* U- |
$ p, J0 F5 M, i. ]/ s! U/* assign the tl som board LED-GPIOs*/
4 f! g) h' _4 K5 [! gstatic const short da850_evm_tl_user_led_pins[] = {0 S- n& m) e* t0 ^7 |6 O
/* These pins are definition at <mach/mux.h> file */! M2 {) a7 E" t: {9 v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) N* D$ w( N8 I, f( t) h& Y
-11 n) b0 Z1 }( n9 R5 s5 t0 ^
};1 j1 |0 h# f5 @ [" _
0 b8 K# s% v, a1 [: Jstatic struct gpio_led da850_evm_tl_leds[] = {
2 _7 o- |0 {1 }4 ^* }3 ~! d4 m {
e1 |$ N% ?) O2 [; b .active_low = 0,
9 U! R4 e6 T# C0 G3 c .gpio = DA850_USER_LED0,- D6 F0 F! T! I4 @$ f+ j% b
.name = "user_led0",2 D9 p, t* H: n
.default_trigger = "default-on",
5 i W1 W' \4 T' n$ j' T" ? },
* ?( D5 I$ p5 G6 G5 y D {' m: ]; m% f. N' W1 h: J
.active_low = 0,
. J0 H) z( g& m .gpio = DA850_USER_LED1,/ X7 S3 Q7 [# y! N5 E
.name = "user_led1",
) b/ y2 | t% C0 |% G .default_trigger = "default-on",
/ c& ?, o. _) M- G1 x" } },
, z! O7 M/ N+ g# a; @* }5 V {
6 S- V- E; i4 T/ X1 x .active_low = 0,
6 E9 N) d' `" @% w; d7 _# D7 V .gpio = DA850_USER_LED2,; m6 [4 `% T) C K: b8 D# I9 C
.name = "user_led2",
! B/ Z; ]3 g0 t8 e6 o; n .default_trigger = "default-on",5 E# v3 w7 Q$ O/ \, Z
},7 S3 P( k# A: c/ O) {
{6 j1 | ~7 F# W7 F. F
.active_low = 0,
8 s [( s( G" ^7 H) U .gpio = DA850_USER_LED3,
9 i$ Y N& g, J. j# H: l .name = "user_led3",
: O2 ~5 y4 y# t/ ~% j: b$ r; K .default_trigger = "default-on",
5 s# m( G; m7 J) C },5 M) @9 @$ O& H, d
};/ S5 P& ^5 _7 ?2 c# r, M
5 ~# u; [" |8 d: c1 Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" Z5 @0 s# a: G, c& P3 p9 { .leds = da850_evm_tl_leds,1 D+ o3 q: `/ Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' I' V/ R2 u. f8 S2 D$ Y& P/ f
};! z0 f, r1 D6 r7 S7 ?) N0 P
' A. @" Z2 g- vstatic void led_dev_release(struct device *dev)7 A* O! W4 g# `' L/ i1 g
{
L6 E/ m7 r9 ?9 M+ [& P4 V6 }};1 I- \- d) W1 M5 i& W
, v- n+ o5 I$ o; s# {: Wstatic struct platform_device da850_evm_tl_leds_device = {
. F' X. n6 @8 Q2 \7 @$ g! K .name = "leds-gpio",9 v5 n# W8 l# {' a4 d6 H
.id = 1,) ^% p' `7 K9 A% v. [: d
.dev = {* a% |; J7 D* ]9 R
.platform_data = &da850_evm_tl_leds_pdata,
5 z2 I, y! `2 o/ Q( Q .release = led_dev_release,
# k! a _! K+ T! A" V/ k }0 `& U1 l7 i+ J" d+ C
};
1 O( ^: x" B) o+ A0 e& m* X# @+ [$ w1 F( n1 t/ F* X, R
static int __init led_platform_init(void)
5 l1 a; t6 F& k4 c{
& d& b# i w% C: y0 p0 p$ l3 m int ret;
6 z3 c" S9 [/ X7 j I$ k, U: ?#if 0
& K6 b" m1 H3 ]: b+ u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 Q6 J3 @) @# Y if (ret)
+ H6 m) [8 X" R! }" U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 k$ V4 W8 k. z5 d
"%d\n", ret);
( y4 T; c( {; E/ F. Q8 E5 Q. b#endif* w, k3 ]9 o' x- U, A# O
ret = platform_device_register(&da850_evm_tl_leds_device);4 v+ k) w) v& V) }. v6 M
if (ret)) w* ?3 {1 B3 ^, Y& X
pr_warning("Could not register som GPIO expander LEDS");
/ p4 r* h9 h; U% c& W& ~. r. `$ N else
3 ~6 N8 \5 S2 j0 { printk(KERN_INFO "LED register sucessful!\n");
, w& s/ ^: K- O2 e5 M; m E7 w! L5 O. U5 \) I. T
return ret;
3 w) J0 [ C) ] ?$ O) s, E}
* O$ {6 N! w4 P. |# L9 e2 J' j
4 i* N7 P4 _( F Mstatic void __exit led_platform_exit(void)8 T. `8 L- i' B* ^
{
+ Y5 l% Y# @; G6 j8 W platform_device_unregister(&da850_evm_tl_leds_device);6 `8 v* j8 g( B4 j* `. b& R
9 d$ Y; R2 E- d# O( h3 E4 m printk(KERN_INFO "LED unregister!\n");
! k( c& y; E2 v* w$ `% R}
& K9 a* v3 N( c" @! O/ j5 c
: g/ X9 r; K1 H7 v1 g9 W. d, c. xmodule_init(led_platform_init);
7 F" U2 k3 q% |9 m# mmodule_exit(led_platform_exit);
& a3 }- N w- U/ I7 D1 G8 X+ V
' \. o9 Z' e& Z* F4 ZMODULE_DESCRIPTION("Led platform driver");* ~+ u S. A' G' g# t5 q
MODULE_AUTHOR("Tronlong");4 I1 F# X) G. r
MODULE_LICENSE("GPL");5 M; Z# }5 v' y" d I8 j. w1 n
% A- l) T8 Y" h0 `3 g$ d+ B
|
|