|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 R* `7 Z5 e. C- y#include <linux/init.h>
; b7 C0 E% c; U" _0 s#include <linux/module.h>6 R$ m( @% O# E8 M0 X
#include <linux/kernel.h>% ~; w& {7 D( M" X& @: o
#include <linux/types.h># E* H7 R# f: A4 I) K# ]% }6 d
#include <linux/gpio.h>7 C d. Y+ H3 `, R: r& Y
#include <linux/leds.h>
3 m8 U+ D( V6 j C9 V# k8 X4 z D#include <linux/platform_device.h>; w' V* |, u1 t1 r
. v: `9 b! y7 m3 |* W. _
#include <asm/mach-types.h>
: H" D3 u/ s, c* N# B8 l$ s#include <asm/mach/arch.h>* a0 Q' \0 p0 @( }2 P% g5 r3 n
#include <mach/da8xx.h>
1 @6 A, h. R6 @5 c$ [#include <mach/mux.h>
7 c% L2 |& Q2 D$ f
4 A! q- y3 a6 r#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( N2 y% g4 Z7 V7 `* A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 V2 N/ l/ \9 @0 Q& I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 w2 M" o6 v+ i! Z( X i& E#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
Z, ^0 |( d0 {6 [. d% n" E( Z- D9 U C- E! _3 \
/* assign the tl som board LED-GPIOs*/
+ y- y+ D( t; H7 q: H: G. h3 Ystatic const short da850_evm_tl_user_led_pins[] = {
, q5 C. d I2 Q /* These pins are definition at <mach/mux.h> file */& [* `* e2 n) x; F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' I9 z- D8 _* o9 N1 S+ w
-1* b2 K, A6 l. ?& u+ ^8 i
};& \" b/ B4 @* s
1 U0 R1 y; ]" j5 c H k* H$ l
static struct gpio_led da850_evm_tl_leds[] = {
* G7 C1 R5 t U# Y! q {
! Z( V% k* u% D/ W .active_low = 0,6 i/ Y$ V0 g( M
.gpio = DA850_USER_LED0,
( u& b+ W5 O6 Z/ u8 j4 b( A, I .name = "user_led0",) k# d. G* P, \' s O
.default_trigger = "default-on",
- \% h9 E4 [7 ~, h) ? v- [ },9 b* T# @# c# F( w+ T1 i1 z8 w$ S
{
% i( [$ x% g: E9 _7 \% v) e .active_low = 0,& J2 M. b0 u9 X8 H
.gpio = DA850_USER_LED1,
2 o) |' w6 d- ~1 o- A3 x2 T .name = "user_led1",
& H: @) W. }) B g .default_trigger = "default-on",/ E0 s0 @& X( ?) f# ?" S, t
},! K5 W+ E$ Z3 v' p& P
{
" y* V2 E* A' e2 d .active_low = 0,
Q1 t! [! M+ ^3 k3 A& N2 S3 w .gpio = DA850_USER_LED2,
2 D8 c% s+ P( q8 d! V" \ .name = "user_led2",
. D8 {: o8 B2 i( U .default_trigger = "default-on",
$ x3 `! Y5 F3 [$ M8 a },
9 Q* l) d0 P6 c8 ^1 N8 [ {* ]% E. F4 {2 {
.active_low = 0,
* l0 v9 ?6 D) l9 o3 G .gpio = DA850_USER_LED3,
2 Y' V5 E( _- U0 B0 W .name = "user_led3",
3 s: t, ]' A/ x .default_trigger = "default-on",
5 [" G8 Y( g- t% N. y( } },
6 N0 K2 R$ X7 ^" Q- M/ E$ [3 D};
: K( y, p9 z$ |* W& m7 V( x* j2 |' M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! \$ _3 x# o2 `7 [& g+ k, B, Y
.leds = da850_evm_tl_leds,5 A# {! r# x a: a% |/ O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) C, ]- q: a& G9 t$ i. ^! E};- H. w( U/ X& Q7 q8 R/ ^% z3 D7 t; e; t
5 ~' j1 N& e9 i( p4 cstatic void led_dev_release(struct device *dev)
. p1 K* _% W1 n& M9 N" }- ^' E. g, j{
5 i. j. g4 Y2 p. A! ^ @; h% _) I};, x$ G5 r0 I2 b$ G/ [ ` D0 |+ ]8 t
- s9 ^( q$ V l* v0 x" H: Rstatic struct platform_device da850_evm_tl_leds_device = {
2 ^. X5 g) _1 O: K3 ?" p& e- O .name = "leds-gpio",
, t1 _, |$ \- `4 h: h .id = 1,0 _) N# l7 X9 f5 W& V
.dev = {! i- d. B4 e ?- y7 Z" w5 D
.platform_data = &da850_evm_tl_leds_pdata,
7 h; ?/ e4 T4 O6 O .release = led_dev_release," V% R4 _" Z' Z O9 @# u$ y
}9 [# M1 H) Z! g' o8 v- P
};5 m+ O3 w7 M. P. C% r+ D
9 k7 X6 F/ F2 ~' H+ S
static int __init led_platform_init(void)
- l- E" P' R/ k. P. C( o9 B; T- z p{& j. @" M0 x* O0 c& R! s" ? @9 s
int ret;
! C1 u$ T5 h1 U L#if 0
2 |+ v4 z! c0 P4 h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 E7 _, b( {. f" p/ v
if (ret)
* e! A) u% x6 ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ M9 h: o) |* ?: k4 _% v" }
"%d\n", ret);
- {6 h5 c' k" M& B% X @#endif/ H7 y; T: q% p. L/ S+ Z
ret = platform_device_register(&da850_evm_tl_leds_device);
( U$ s& o' Z% O, q if (ret), O7 }0 k2 U) Z+ e
pr_warning("Could not register som GPIO expander LEDS");
- f1 R+ a: m& {% B8 q, ~, T else
9 A/ _! w, ?+ c! ?% d, Z printk(KERN_INFO "LED register sucessful!\n");% k' n2 S0 Q) K h+ a6 x, e2 M" z. q) E
/ T O3 C% v3 g9 A: r |0 d% p
return ret;
' G: \4 k! Y& K) x2 U" z}
2 j* B6 R1 q& d) @: _0 r0 x& q1 M) N
static void __exit led_platform_exit(void)
, [4 S" u0 p5 k0 F{
; k) X4 \; j( j: o$ `- ^. m G platform_device_unregister(&da850_evm_tl_leds_device);& x2 ~9 { q3 h. ?6 }1 n, Q
J: c7 m5 S1 k, Q& P. u8 C, O printk(KERN_INFO "LED unregister!\n");
; L3 t" o3 q8 S! O' I. }}
, n0 r5 w6 b) N* G
; z+ x8 ^9 ^; X) smodule_init(led_platform_init);0 ?6 F1 `6 a% ?2 j0 M7 o
module_exit(led_platform_exit);
( Y4 d5 @% H. N: U8 U, ~
8 u9 }6 t% i4 h F6 a" b. }2 tMODULE_DESCRIPTION("Led platform driver");
. l8 e C# y: V' A" mMODULE_AUTHOR("Tronlong");7 ]# |/ A: ?+ x6 t2 n* A
MODULE_LICENSE("GPL");' h! o; k& ~" ]3 p& f# ^+ K3 L/ _! Z
U* ]3 q8 A3 M; }
|
|